Java Code Examples for android.view.View#LAYOUT_DIRECTION_RTL
The following examples show how to use
android.view.View#LAYOUT_DIRECTION_RTL .
These examples are extracted from open source projects.
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 Project: LB-Launcher File: DeviceProfile.java License: Apache License 2.0 | 6 votes |
void updateFromConfiguration(Context context, Resources resources, int wPx, int hPx, int awPx, int ahPx) { Configuration configuration = resources.getConfiguration(); isLandscape = (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE); isTablet = resources.getBoolean(R.bool.is_tablet); isLargeTablet = resources.getBoolean(R.bool.is_large_tablet); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { isLayoutRtl = (configuration.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL); } else { isLayoutRtl = false; } widthPx = wPx; heightPx = hPx; availableWidthPx = awPx; availableHeightPx = ahPx; updateAvailableDimensions(context); }
Example 2
Source Project: styT File: PromptUtils.java License: Apache License 2.0 | 6 votes |
/** * Determines if the text in the supplied layout is displayed right to left. * * @param layout The layout to check. * @return True if the text in the supplied layout is displayed right to left. False otherwise. */ public static boolean isRtlText(@Nullable final Layout layout, @NonNull final Resources resources) { boolean result = false; if (layout != null) { // Treat align opposite as right to left by default result = layout.getAlignment() == Layout.Alignment.ALIGN_OPPOSITE; // If the first character is a right to left character final boolean textIsRtl = layout.isRtlCharAt(0); // If the text and result are right to left then false otherwise use the textIsRtl value result = (!(result && textIsRtl) && !(!result && !textIsRtl)) || textIsRtl; if (!result && layout.getAlignment() == Layout.Alignment.ALIGN_NORMAL && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { // If the layout and text are right to left and the alignment is normal then rtl result = resources.getConfiguration() .getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; } else if (layout.getAlignment() == Layout.Alignment.ALIGN_OPPOSITE && textIsRtl) { result = false; } } return result; }
Example 3
Source Project: rtl-viewpager File: RtlViewPager.java License: Apache License 2.0 | 6 votes |
@Override public void onRtlPropertiesChanged(int layoutDirection) { super.onRtlPropertiesChanged(layoutDirection); int viewCompatLayoutDirection = layoutDirection == View.LAYOUT_DIRECTION_RTL ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR; if (viewCompatLayoutDirection != mLayoutDirection) { PagerAdapter adapter = super.getAdapter(); int position = 0; if (adapter != null) { position = getCurrentItem(); } mLayoutDirection = viewCompatLayoutDirection; if (adapter != null) { adapter.notifyDataSetChanged(); setCurrentItem(position); } } }
Example 4
Source Project: 365browser File: MaterialProgressDrawable.java License: Apache License 2.0 | 5 votes |
private static boolean isLayoutRtl(View view) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { return view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; } else { // All layouts are LTR before JB MR1. return false; } }
Example 5
Source Project: v2ex File: UIUtils.java License: Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public static boolean isRtl(final Context context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { return false; } else { return context.getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; } }
Example 6
Source Project: BottomSheetPickers File: LocaleModel.java License: Apache License 2.0 | 5 votes |
boolean isLayoutRtl() { if (Build.VERSION.SDK_INT >= 17) { return mAppContext.getResources().getConfiguration() .getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; } else { // There is only LTR before SDK 17. return false; } }
Example 7
Source Project: Android-ObservableScrollView File: FlexibleSpaceWithImageGridViewActivity.java License: Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private void setPivotXToTitle() { Configuration config = getResources().getConfiguration(); if (Build.VERSION_CODES.JELLY_BEAN_MR1 <= Build.VERSION.SDK_INT && config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { ViewHelper.setPivotX(mTitleView, findViewById(android.R.id.content).getWidth()); } else { ViewHelper.setPivotX(mTitleView, 0); } }
Example 8
Source Project: Android-Next File: ViewUtils.java License: Apache License 2.0 | 5 votes |
/** * 23 * Returns true if view's layout direction is right-to-left. * 24 * * 25 * @param view the View whose layout is being considered * 26 */ public static boolean isLayoutRtl(View view) { if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) { return view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; } else { // All layouts are LTR before JB MR1. return false; } }
Example 9
Source Project: PowerFileExplorer File: ShowHidePasswordEditText.java License: GNU General Public License v3.0 | 5 votes |
private boolean isLeftToRight() { // If we are pre JB assume always LTR if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { return true; } // Other methods, seemingly broken when testing though. // return ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL // return !ViewUtils.isLayoutRtl(this); Configuration config = getResources().getConfiguration(); return !(config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL); }
Example 10
Source Project: XERUNG File: MaterialMultiAutoCompleteTextView.java License: Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private boolean isRTL() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { return false; } Configuration config = getResources().getConfiguration(); return config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; }
Example 11
Source Project: deltachat-android File: ViewUtil.java License: GNU General Public License v3.0 | 5 votes |
@SuppressLint("RtlHardcoded") public static void setTextViewGravityStart(final @NonNull TextView textView, @NonNull Context context) { if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) { if (DynamicLanguage.getLayoutDirection(context) == View.LAYOUT_DIRECTION_RTL) { textView.setGravity(Gravity.RIGHT); } else { textView.setGravity(Gravity.LEFT); } } }
Example 12
Source Project: android-chromium File: LocalizationUtils.java License: BSD 2-Clause "Simplified" License | 5 votes |
/** * @return true if the system default layout direction is RTL, false otherwise. * RTL layout support is from Jelly Bean MR1, so if the version is lower * than that, it is always false. */ public static boolean isSystemLayoutDirectionRtl() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { return TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL; } return false; }
Example 13
Source Project: litho File: Layout.java License: Apache License 2.0 | 5 votes |
@VisibleForTesting static boolean isLayoutDirectionRTL(final Context context) { ApplicationInfo applicationInfo = context.getApplicationInfo(); if ((SDK_INT >= JELLY_BEAN_MR1) && (applicationInfo.flags & ApplicationInfo.FLAG_SUPPORTS_RTL) != 0) { int layoutDirection = getLayoutDirection(context); return layoutDirection == View.LAYOUT_DIRECTION_RTL; } return false; }
Example 14
Source Project: mollyim-android File: ConversationItemSwipeCallback.java License: GNU General Public License v3.0 | 4 votes |
private static float getSignFromDirection(@NonNull View view) { return view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL ? -1f : 1f; }
Example 15
Source Project: LB-Launcher File: ButtonDropTarget.java License: Apache License 2.0 | 4 votes |
private boolean isRtl() { return (getLayoutDirection() == View.LAYOUT_DIRECTION_RTL); }
Example 16
Source Project: prayer-times-android File: BaseActivity.java License: Apache License 2.0 | 4 votes |
protected boolean isRTL() { Configuration config = getResources().getConfiguration(); return config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; }
Example 17
Source Project: Transitions-Everywhere File: ViewUtils.java License: Apache License 2.0 | 4 votes |
@Override public boolean isRtl(@NonNull View view) { return view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; }
Example 18
Source Project: BreadcrumbsView File: ViewUtils.java License: MIT License | 2 votes |
/** * Check if the current language is RTL * * @param context Context * @return Result */ static boolean isRtlLayout(Context context) { return context.getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; }
Example 19
Source Project: android_9.0.0_r45 File: BidiFormatter.java License: 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 (TextUtils.getLayoutDirectionFromLocale(locale) == View.LAYOUT_DIRECTION_RTL); }
Example 20
Source Project: android_9.0.0_r45 File: Configuration.java License: Apache License 2.0 | 2 votes |
/** * Return the layout direction. Will be either {@link View#LAYOUT_DIRECTION_LTR} or * {@link View#LAYOUT_DIRECTION_RTL}. * * @return Returns {@link View#LAYOUT_DIRECTION_RTL} if the configuration * is {@link #SCREENLAYOUT_LAYOUTDIR_RTL}, otherwise {@link View#LAYOUT_DIRECTION_LTR}. */ public int getLayoutDirection() { return (screenLayout&SCREENLAYOUT_LAYOUTDIR_MASK) == SCREENLAYOUT_LAYOUTDIR_RTL ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR; }