List of usage examples for android.view View LAYOUT_DIRECTION_RTL
int LAYOUT_DIRECTION_RTL
To view the source code for android.view View LAYOUT_DIRECTION_RTL.
Click Source Link
From source file:com.android.contacts.activities.PeopleActivity.java
private boolean isRTL() { final Locale locale = Locale.getDefault(); return TextUtils.getLayoutDirectionFromLocale(locale) == View.LAYOUT_DIRECTION_RTL; }
From source file:com.android.contacts.list.DefaultContactBrowseListFragment.java
private int getScrollBarPosition() { final Locale locale = Locale.getDefault(); final boolean isRTL = TextUtils.getLayoutDirectionFromLocale(locale) == View.LAYOUT_DIRECTION_RTL; return isRTL ? View.SCROLLBAR_POSITION_LEFT : View.SCROLLBAR_POSITION_RIGHT; }
From source file:android.support.v17.leanback.widget.GuidedActionsStylist.java
/** * Sets states of chevron view, called by {@link #onBindViewHolder(ViewHolder, GuidedAction)}. * Subclass may override.// ww w . j av a2s. c om * * @param vh The view holder associated with the relevant action. * @param action The GuidedAction object to bind to. */ public void onBindChevronView(ViewHolder vh, GuidedAction action) { final boolean hasNext = action.hasNext(); final boolean hasSubActions = action.hasSubActions(); if (hasNext || hasSubActions) { vh.mChevronView.setVisibility(View.VISIBLE); vh.mChevronView.setAlpha(action.isEnabled() ? mEnabledChevronAlpha : mDisabledChevronAlpha); if (hasNext) { float r = mMainView != null && mMainView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL ? 180f : 0f; vh.mChevronView.setRotation(r); } else if (action == mExpandedAction) { vh.mChevronView.setRotation(270); } else { vh.mChevronView.setRotation(90); } } else { vh.mChevronView.setVisibility(View.GONE); } }
From source file:de.azapps.mirakel.main_activity.MainActivity.java
/** * Loads the settings/*from w ww . j a va 2 s .c o m*/ */ @SuppressLint("NewApi") private void initConfiguration() { Locale.setDefault(Helpers.getLocal(this)); MainActivity.isRTL = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; this.currentPosition = MainActivity.getTasksFragmentPosition(); this.mPagerAdapter = null; Log.d(MainActivity.TAG, "false"); this.startIntent = getIntent(); this.closeOnBack = false; }
From source file:com.android.launcher3.Utilities.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public static boolean isRtl(Resources res) { return ATLEAST_JB_MR1 && (res.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL); }
From source file:com.jecelyin.editor.v2.core.text.TextUtils.java
/** * 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 android.view.View#LAYOUT_DIRECTION_LTR} or * {@link android.view.View#LAYOUT_DIRECTION_RTL}. * * Be careful: this code will need to be updated when vertical scripts will be supported *///from w w w . j a v a 2 s. co m public static int getLayoutDirectionFromLocale(Locale locale) { if (locale != null && !locale.equals(Locale.ROOT)) { // final String scriptSubtag = ICU.addLikelySubtags(locale).getScript(); final String scriptSubtag = ICUCompat.maximizeAndGetScript(locale); if (scriptSubtag == null) return getLayoutDirectionFromFirstChar(locale); if (scriptSubtag.equalsIgnoreCase(ARAB_SCRIPT_SUBTAG) || scriptSubtag.equalsIgnoreCase(HEBR_SCRIPT_SUBTAG)) { return View.LAYOUT_DIRECTION_RTL; } } // If forcing into RTL layout mode, return RTL as default, else LTR // return SystemProperties.getBoolean(Settings.Global.DEVELOPMENT_FORCE_RTL, false) // ? View.LAYOUT_DIRECTION_RTL // : View.LAYOUT_DIRECTION_LTR; return View.LAYOUT_DIRECTION_LTR; //jec: ? }
From source file:com.jecelyin.editor.v2.core.text.TextUtils.java
/** * Fallback algorithm to detect the locale direction. Rely on the fist char of the * localized locale name. This will not work if the localized locale name is in English * (this is the case for ICU 4.4 and "Urdu" script) * * @param locale/*from w w w.j a v a 2 s . com*/ * @return the layout direction. This may be one of: * {@link android.view.View#LAYOUT_DIRECTION_LTR} or * {@link android.view.View#LAYOUT_DIRECTION_RTL}. * * Be careful: this code will need to be updated when vertical scripts will be supported * * @hide */ private static int getLayoutDirectionFromFirstChar(Locale locale) { switch (Character.getDirectionality(locale.getDisplayName(locale).charAt(0))) { case Character.DIRECTIONALITY_RIGHT_TO_LEFT: case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC: return View.LAYOUT_DIRECTION_RTL; case Character.DIRECTIONALITY_LEFT_TO_RIGHT: default: return View.LAYOUT_DIRECTION_LTR; } }
From source file:com.facebook.litho.MountState.java
private static void setViewLayoutDirection(View view, ViewNodeInfo viewNodeInfo) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { return;// w w w . j av a 2 s . c o m } final int viewLayoutDirection; switch (viewNodeInfo.getLayoutDirection()) { case LTR: viewLayoutDirection = View.LAYOUT_DIRECTION_LTR; break; case RTL: viewLayoutDirection = View.LAYOUT_DIRECTION_RTL; break; default: viewLayoutDirection = View.LAYOUT_DIRECTION_INHERIT; } view.setLayoutDirection(viewLayoutDirection); }
From source file:io.github.clendy.leanback.widget.GridLayoutManager.java
private void layoutChild(int rowIndex, View v, int start, int end, int startSecondary) { if (TRACE)//from w w w .ja v a2 s. com TraceHelper.beginSection("layoutChild"); int sizeSecondary = mOrientation == HORIZONTAL ? v.getMeasuredHeight() : v.getMeasuredWidth(); if (mFixedRowSizeSecondary > 0) { sizeSecondary = Math.min(sizeSecondary, mFixedRowSizeSecondary); } final int verticalGravity = mGravity & Gravity.VERTICAL_GRAVITY_MASK; final int horizontalGravity = (mReverseFlowPrimary || mReverseFlowSecondary) ? Gravity.getAbsoluteGravity(mGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK, View.LAYOUT_DIRECTION_RTL) : mGravity & Gravity.HORIZONTAL_GRAVITY_MASK; if (mOrientation == HORIZONTAL && verticalGravity == Gravity.TOP || mOrientation == VERTICAL && horizontalGravity == Gravity.LEFT) { // do nothing } else if (mOrientation == HORIZONTAL && verticalGravity == Gravity.BOTTOM || mOrientation == VERTICAL && horizontalGravity == Gravity.RIGHT) { startSecondary += getRowSizeSecondary(rowIndex) - sizeSecondary; } else if (mOrientation == HORIZONTAL && verticalGravity == Gravity.CENTER_VERTICAL || mOrientation == VERTICAL && horizontalGravity == Gravity.CENTER_HORIZONTAL) { startSecondary += (getRowSizeSecondary(rowIndex) - sizeSecondary) / 2; } int left, top, right, bottom; if (mOrientation == HORIZONTAL) { left = start; top = startSecondary; right = end; bottom = startSecondary + sizeSecondary; } else { top = start; left = startSecondary; bottom = end; right = startSecondary + sizeSecondary; } v.layout(left, top, right, bottom); updateChildOpticalInsets(v, left, top, right, bottom); updateChildAlignments(v); if (TRACE) TraceHelper.endSection(); }
From source file:com.rbware.github.androidcouchpotato.widget.GridLayoutManager.java
void layoutChild(int rowIndex, View v, int start, int end, int startSecondary) { if (TRACE)/*from w ww . j a v a2 s .co m*/ TraceHelper.beginSection("layoutChild"); int sizeSecondary = mOrientation == HORIZONTAL ? getDecoratedMeasuredHeightWithMargin(v) : getDecoratedMeasuredWidthWithMargin(v); if (mFixedRowSizeSecondary > 0) { sizeSecondary = Math.min(sizeSecondary, mFixedRowSizeSecondary); } final int verticalGravity = mGravity & Gravity.VERTICAL_GRAVITY_MASK; final int horizontalGravity = (mReverseFlowPrimary || mReverseFlowSecondary) ? Gravity.getAbsoluteGravity(mGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK, View.LAYOUT_DIRECTION_RTL) : mGravity & Gravity.HORIZONTAL_GRAVITY_MASK; if (mOrientation == HORIZONTAL && verticalGravity == Gravity.TOP || mOrientation == VERTICAL && horizontalGravity == Gravity.LEFT) { // do nothing } else if (mOrientation == HORIZONTAL && verticalGravity == Gravity.BOTTOM || mOrientation == VERTICAL && horizontalGravity == Gravity.RIGHT) { startSecondary += getRowSizeSecondary(rowIndex) - sizeSecondary; } else if (mOrientation == HORIZONTAL && verticalGravity == Gravity.CENTER_VERTICAL || mOrientation == VERTICAL && horizontalGravity == Gravity.CENTER_HORIZONTAL) { startSecondary += (getRowSizeSecondary(rowIndex) - sizeSecondary) / 2; } int left, top, right, bottom; if (mOrientation == HORIZONTAL) { left = start; top = startSecondary; right = end; bottom = startSecondary + sizeSecondary; } else { top = start; left = startSecondary; bottom = end; right = startSecondary + sizeSecondary; } LayoutParams params = (LayoutParams) v.getLayoutParams(); layoutDecoratedWithMargins(v, left, top, right, bottom); // Now super.getDecoratedBoundsWithMargins() includes the extra space for optical bounds, // subtracting it from value passed in layoutDecoratedWithMargins(), we can get the optical // bounds insets. super.getDecoratedBoundsWithMargins(v, sTempRect); params.setOpticalInsets(left - sTempRect.left, top - sTempRect.top, sTempRect.right - right, sTempRect.bottom - bottom); updateChildAlignments(v); if (TRACE) TraceHelper.endSection(); }