@Override public boolean isRtl(@NonNull View view) { return view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; } }
@SuppressLint("NewApi") static int getLayoutDirection(View v) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { return v.getLayoutDirection(); } return View.LAYOUT_DIRECTION_LTR; } }
@TargetApi(JELLY_BEAN_MR1) public S hasLayoutDirection(int direction) { isNotNull(); int actualDirection = actual.getLayoutDirection(); assertThat(actualDirection) // .overridingErrorMessage("Expected layout direction <%s> but was <%s>", layoutDirectionToString(direction), layoutDirectionToString(actualDirection)) // .isEqualTo(direction); return myself; }
return Gravity.getAbsoluteGravity(gravity, drawerView.getLayoutDirection());
/** * Tests to make sure the layout direction set on the component tree is correctly propagated to * mounted views. */ @Test public void testLayoutDirectionPropagation() { final TestComponent child = create(mContext) .build(); LithoView lithoView = mountComponent( mContext, new InlineLayoutSpec() { @Override protected Component onCreateLayout(ComponentContext c) { return Column.create(c).layoutDirection(RTL).child(child).build(); } }); final View childView = lithoView.getChildAt(0); assertThat(childView.getLayoutDirection()).isEqualTo(LAYOUT_DIRECTION_RTL); } }
static int getLayoutDirection(View view) { if (Build.VERSION.SDK_INT >= 17) { return view.getLayoutDirection(); } return LAYOUT_DIRECTION_LTR; }
/** * Returns a boolean indicating whether or not the view's layout direction is RTL * * @param view - A valid view * @return True if the view's layout direction is RTL */ public static boolean isViewLayoutRtl(View view) { return view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; }
/** * Returns a boolean indicating whether or not the view's layout direction is RTL * * @param view - A valid view * @return True if the view's layout direction is RTL */ public static boolean isViewLayoutRtl(View view) { return view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; }
public static int getLayoutDirection(View view) { return view.getLayoutDirection(); }
private boolean isLayoutRtl() { return mFloatingActionButtonContainer.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; } }
private int viewGetEnd(View view) { int layoutDirection = view.getLayoutDirection(); switch (layoutDirection) { case View.LAYOUT_DIRECTION_RTL: return view.getLeft(); case View.LAYOUT_DIRECTION_LTR: default: return view.getRight(); } }
/** * Creates an {@link android.graphics.drawable.InsetDrawable} according to the layout direction * of {@code view}. */ public static InsetDrawable createRelativeInsetDrawable(Drawable drawable, int insetStart, int insetTop, int insetEnd, int insetBottom, View view) { boolean isRtl = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; return createRelativeInsetDrawable(drawable, insetStart, insetTop, insetEnd, insetBottom, isRtl); }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private boolean isRtl() { return getView().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private boolean isRtl() { return getView().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private boolean isRtl() { return getView().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; }
@TargetApi(JELLY_BEAN_MR1) public S hasLayoutDirection(int direction) { isNotNull(); int actualDirection = actual.getLayoutDirection(); assertThat(actualDirection) // .overridingErrorMessage("Expected layout direction <%s> but was <%s>", layoutDirectionToString(direction), layoutDirectionToString(actualDirection)) // .isEqualTo(direction); return myself; }
/** * Creates a tool tip view. */ @UiThread public ToolTipView build() { if (gravity == GRAVITY_START || gravity == GRAVITY_END) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && anchorView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { gravity = gravity == GRAVITY_START ? Gravity.RIGHT : Gravity.LEFT; } else { gravity &= Gravity.HORIZONTAL_GRAVITY_MASK; } } if (gravity != Gravity.TOP && gravity != Gravity.BOTTOM && gravity != Gravity.LEFT && gravity != Gravity.RIGHT) { throw new IllegalArgumentException("Unsupported gravity - " + gravity); } return new ToolTipView(context, anchorView, gravity, toolTip); } }
@TargetApi(JELLY_BEAN_MR1) @CheckResult private boolean needMirroring() { if (isAutoMirrored()) { if (SDK_INT >= M) { return getLayoutDirection() == LayoutDirection.RTL; } // Since getLayoutDirection() is hidden prior to Marshmallow, we // will try to get the layout direction from the View, which we will // assume is set as the callback. As the setLayoutDirection() method // is also hidden, we can safely rely on the behaviour of the // platform Views to provide a correct replacement for the hidden // method. Callback callback = getCallback(); if (callback instanceof View) { return ((View) callback).getLayoutDirection() == LAYOUT_DIRECTION_RTL; } } return false; }
public ContactListPinnedHeaderView(Context context, AttributeSet attrs, View parent) { super(context, attrs); if (R.styleable.ContactListItemView == null) { return; } TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ContactListItemView); int backgroundColor = a.getColor( R.styleable.ContactListItemView_list_item_background_color, Color.WHITE); int textOffsetTop = a.getDimensionPixelSize( R.styleable.ContactListItemView_list_item_text_offset_top, 0); int paddingStartOffset = a.getDimensionPixelSize( R.styleable.ContactListItemView_list_item_padding_left, 0); int textWidth = getResources().getDimensionPixelSize( R.dimen.contact_list_section_header_width); int widthIncludingPadding = paddingStartOffset + textWidth; a.recycle(); setBackgroundColor(backgroundColor); setTextAppearance(getContext(), R.style.SectionHeaderStyle); setLayoutParams(new LayoutParams(widthIncludingPadding, LayoutParams.WRAP_CONTENT)); setLayoutDirection(parent.getLayoutDirection()); setGravity(Gravity.CENTER_VERTICAL | (ViewUtil.isViewLayoutRtl(this) ? Gravity.RIGHT : Gravity.LEFT)); // Apply text top offset. Multiply by two, because we are implementing this by padding for a // vertically centered view, rather than adjusting the position directly via a layout. setPaddingRelative( getPaddingStart() + paddingStartOffset, getPaddingTop() + (textOffsetTop * 2), getPaddingEnd(), getPaddingBottom()); }
if (((host.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) && layout.isRegionVacant(info.cellX - 1, info.cellY, 1, info.spanY)) || !layout.isRegionVacant(info.cellX + info.spanX, info.cellY, 1, info.spanY)) {