Java Code Examples for android.support.v4.view.ViewCompat#LAYOUT_DIRECTION_RTL
The following examples show how to use
android.support.v4.view.ViewCompat#LAYOUT_DIRECTION_RTL .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SetupStartIndicatorView.java From Indic-Keyboard with Apache License 2.0 | 6 votes |
@Override protected void onDraw(final Canvas canvas) { super.onDraw(canvas); final int layoutDirection = ViewCompat.getLayoutDirection(this); final int width = getWidth(); final int height = getHeight(); final float halfHeight = height / 2.0f; final Path path = mIndicatorPath; path.rewind(); if (layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL) { // Left arrow path.moveTo(width, 0.0f); path.lineTo(0.0f, halfHeight); path.lineTo(width, height); } else { // LAYOUT_DIRECTION_LTR // Right arrow path.moveTo(0.0f, 0.0f); path.lineTo(width, halfHeight); path.lineTo(0.0f, height); } path.close(); final int[] stateSet = getDrawableState(); final int color = mIndicatorColor.getColorForState(stateSet, 0); mIndicatorPaint.setColor(color); canvas.drawPath(path, mIndicatorPaint); }
Example 2
Source File: ActionBarDrawerToggle.java From V.FlyoutTest with MIT License | 6 votes |
@Override public void draw(Canvas canvas) { copyBounds(mTmpRect); canvas.save(); // Layout direction must be obtained from the activity. final boolean isLayoutRTL = ViewCompat.getLayoutDirection( mActivity.getWindow().getDecorView()) == ViewCompat.LAYOUT_DIRECTION_RTL; final int flipRtl = isLayoutRTL ? -1 : 1; final int width = mTmpRect.width(); canvas.translate(-mOffset * width * mPosition * flipRtl, 0); // Force auto-mirroring if it's not supported by the platform. if (isLayoutRTL && !mHasMirroring) { canvas.translate(width, 0); canvas.scale(-1, 1); } super.draw(canvas); canvas.restore(); }
Example 3
Source File: TextUtilsCompat.java From android-recipes-app with Apache License 2.0 | 5 votes |
/** * Return the layout direction for a given Locale * * @param locale the Locale for which we want the layout direction. Can be null. * @return the layout direction. This may be one of: * {@link ViewCompat#LAYOUT_DIRECTION_LTR} or * {@link ViewCompat#LAYOUT_DIRECTION_RTL}. * * Be careful: this code will need to be updated when vertical scripts will be supported */ public static int getLayoutDirectionFromLocale(Locale locale) { if (locale != null && !locale.equals(ROOT)) { final String scriptSubtag = ICUCompat.getScript( ICUCompat.addLikelySubtags(locale.toString())); if (scriptSubtag == null) return getLayoutDirectionFromFirstChar(locale); if (scriptSubtag.equalsIgnoreCase(ARAB_SCRIPT_SUBTAG) || scriptSubtag.equalsIgnoreCase(HEBR_SCRIPT_SUBTAG)) { return ViewCompat.LAYOUT_DIRECTION_RTL; } } return ViewCompat.LAYOUT_DIRECTION_LTR; }
Example 4
Source File: TextUtilsCompat.java From guideshow with MIT License | 5 votes |
/** * Return the layout direction for a given Locale * * @param locale the Locale for which we want the layout direction. Can be null. * @return the layout direction. This may be one of: * {@link ViewCompat#LAYOUT_DIRECTION_LTR} or * {@link ViewCompat#LAYOUT_DIRECTION_RTL}. * * Be careful: this code will need to be updated when vertical scripts will be supported */ public static int getLayoutDirectionFromLocale(Locale locale) { if (locale != null && !locale.equals(ROOT)) { final String scriptSubtag = ICUCompat.getScript( ICUCompat.addLikelySubtags(locale.toString())); if (scriptSubtag == null) return getLayoutDirectionFromFirstChar(locale); if (scriptSubtag.equalsIgnoreCase(ARAB_SCRIPT_SUBTAG) || scriptSubtag.equalsIgnoreCase(HEBR_SCRIPT_SUBTAG)) { return ViewCompat.LAYOUT_DIRECTION_RTL; } } return ViewCompat.LAYOUT_DIRECTION_LTR; }
Example 5
Source File: LinearLayoutManager.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
protected boolean isLayoutRTL() { return getLayoutDirection() == ViewCompat.LAYOUT_DIRECTION_RTL; }
Example 6
Source File: BaseLayoutManager.java From KinoCast with MIT License | 4 votes |
protected boolean isLayoutRTL() { return getLayoutDirection() == ViewCompat.LAYOUT_DIRECTION_RTL; }
Example 7
Source File: CollapsingTitleLayout.java From android-proguards with Apache License 2.0 | 4 votes |
public CollapsingTitleLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); setWillNotDraw(false); paint = new TextPaint(Paint.ANTI_ALIAS_FLAG); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CollapsingTitleLayout); final boolean isRtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL; // first check if all insets set the same titleInsetStart = titleInsetEnd = titleInsetBottom = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInset, 0); titleInsetTop = titleInsetStart; if (a.hasValue(R.styleable.CollapsingTitleLayout_titleInsetStart)) { final int insetStart = a.getDimensionPixelSize( R.styleable.CollapsingTitleLayout_titleInsetStart, 0); if (isRtl) { titleInsetEnd = insetStart; } else { titleInsetStart = insetStart; } } if (a.hasValue(R.styleable.CollapsingTitleLayout_titleInsetTop)) { titleInsetTop = a.getDimensionPixelSize( R.styleable.CollapsingTitleLayout_titleInsetTop, 0); } if (a.hasValue(R.styleable.CollapsingTitleLayout_titleInsetEnd)) { final int insetEnd = a.getDimensionPixelSize( R.styleable.CollapsingTitleLayout_titleInsetEnd, 0); if (isRtl) { titleInsetStart = insetEnd; } else { titleInsetEnd = insetEnd; } } if (a.hasValue(R.styleable.CollapsingTitleLayout_titleInsetBottom)) { titleInsetBottom = a.getDimensionPixelSize( R.styleable.CollapsingTitleLayout_titleInsetBottom, 0); } final int textAppearance = a.getResourceId( R.styleable.CollapsingTitleLayout_android_textAppearance, android.R.style.TextAppearance); TypedArray atp = getContext().obtainStyledAttributes(textAppearance, R.styleable.CollapsingTextAppearance); paint.setColor(atp.getColor(R.styleable.CollapsingTextAppearance_android_textColor, Color.WHITE)); collapsedTextSize = atp.getDimensionPixelSize( R.styleable.CollapsingTextAppearance_android_textSize, 0); if (atp.hasValue(R.styleable.CollapsingTextAppearance_font)) { paint.setTypeface(FontUtil.get(getContext(), atp.getString(R.styleable.CollapsingTextAppearance_font))); } atp.recycle(); if (a.hasValue(R.styleable.CollapsingTitleLayout_collapsedTextSize)) { collapsedTextSize = a.getDimensionPixelSize( R.styleable.CollapsingTitleLayout_collapsedTextSize, 0); paint.setTextSize(collapsedTextSize); } maxExpandedTextSize = a.getDimensionPixelSize( R.styleable.CollapsingTitleLayout_maxExpandedTextSize, Integer.MAX_VALUE); lineHeightHint = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_lineHeightHint, 0); maxLines = a.getInteger(R.styleable.CollapsingTitleLayout_android_maxLines, 5); a.recycle(); }
Example 8
Source File: TextDirectionHeuristicsCompat.java From V.FlyoutTest with MIT License | 4 votes |
@Override protected boolean defaultIsRtl() { final int dir = TextUtilsCompat.getLayoutDirectionFromLocale(java.util.Locale.getDefault()); return (dir == ViewCompat.LAYOUT_DIRECTION_RTL); }
Example 9
Source File: FlexboxLayout.java From JD-Test with Apache License 2.0 | 4 votes |
@Override protected void onDraw(Canvas canvas) { if (mDividerDrawableVertical == null && mDividerDrawableHorizontal == null) { return; } if (mShowDividerHorizontal == SHOW_DIVIDER_NONE && mShowDividerVertical == SHOW_DIVIDER_NONE) { return; } int layoutDirection = ViewCompat.getLayoutDirection(this); boolean isRtl; boolean fromBottomToTop = false; switch (mFlexDirection) { case FLEX_DIRECTION_ROW: isRtl = layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL; if (mFlexWrap == FLEX_WRAP_WRAP_REVERSE) { fromBottomToTop = true; } drawDividersHorizontal(canvas, isRtl, fromBottomToTop); break; case FLEX_DIRECTION_ROW_REVERSE: isRtl = layoutDirection != ViewCompat.LAYOUT_DIRECTION_RTL; if (mFlexWrap == FLEX_WRAP_WRAP_REVERSE) { fromBottomToTop = true; } drawDividersHorizontal(canvas, isRtl, fromBottomToTop); break; case FLEX_DIRECTION_COLUMN: isRtl = layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL; if (mFlexWrap == FLEX_WRAP_WRAP_REVERSE) { isRtl = !isRtl; } fromBottomToTop = false; drawDividersVertical(canvas, isRtl, fromBottomToTop); break; case FLEX_DIRECTION_COLUMN_REVERSE: isRtl = layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL; if (mFlexWrap == FLEX_WRAP_WRAP_REVERSE) { isRtl = !isRtl; } fromBottomToTop = true; drawDividersVertical(canvas, isRtl, fromBottomToTop); break; } }
Example 10
Source File: FloatingSearchView.java From floatingsearchview with Apache License 2.0 | 4 votes |
private boolean isRTL() { Configuration config = getResources().getConfiguration(); return ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL; }
Example 11
Source File: I18nUtil.java From react-native-GPay with MIT License | 4 votes |
private boolean isDevicePreferredLanguageRTL() { final int directionality = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()); return directionality == ViewCompat.LAYOUT_DIRECTION_RTL; }
Example 12
Source File: FastScroller.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private boolean isLayoutRTL() { return ViewCompat.getLayoutDirection(mRecyclerView) == ViewCompat.LAYOUT_DIRECTION_RTL; }
Example 13
Source File: StaggeredGridLayoutManager.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
boolean isLayoutRTL() { return getLayoutDirection() == ViewCompat.LAYOUT_DIRECTION_RTL; }
Example 14
Source File: BaseLayoutManager.java From RecyclerViewLib with Apache License 2.0 | 4 votes |
protected boolean isLayoutRTL() { return getLayoutDirection() == ViewCompat.LAYOUT_DIRECTION_RTL; }
Example 15
Source File: NumberProgressBar.java From FireFiles with Apache License 2.0 | 4 votes |
public boolean isLayoutRtl() { return ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL; }
Example 16
Source File: TabularContextMenuPagerAdapter.java From 365browser with Apache License 2.0 | 4 votes |
/** * Used in combination of a TabLayout to create a multi view layout. * @param views Thew views to use in the pager Adapter. */ TabularContextMenuPagerAdapter(List<Pair<String, ViewGroup>> views) { mViewList = views; mIsRightToLeft = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL; }
Example 17
Source File: TextDirectionHeuristicsCompat.java From adt-leanback-support with Apache License 2.0 | 4 votes |
@Override protected boolean defaultIsRtl() { final int dir = TextUtilsCompat.getLayoutDirectionFromLocale(java.util.Locale.getDefault()); return (dir == ViewCompat.LAYOUT_DIRECTION_RTL); }
Example 18
Source File: LinearLayoutManager.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
protected boolean isLayoutRTL() { return getLayoutDirection() == ViewCompat.LAYOUT_DIRECTION_RTL; }
Example 19
Source File: NumberProgressBar.java From FireFiles with Apache License 2.0 | 4 votes |
public boolean isLayoutRtl() { return ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL; }
Example 20
Source File: BidiFormatter.java From android-recipes-app with Apache License 2.0 | 2 votes |
/** * Helper method to return true if the Locale directionality is RTL. * * @param locale The Locale whose directionality will be checked to be RTL or LTR * @return true if the {@code locale} directionality is RTL. False otherwise. */ private static boolean isRtlLocale(Locale locale) { return (TextUtilsCompat.getLayoutDirectionFromLocale(locale) == ViewCompat.LAYOUT_DIRECTION_RTL); }