android.view.View#LAYOUT_DIRECTION_RTL源码实例Demo

下面列出了android.view.View#LAYOUT_DIRECTION_RTL 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: LB-Launcher   文件: DeviceProfile.java
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);
}
 
源代码2 项目: styT   文件: PromptUtils.java
/**
 * 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;
}
 
源代码3 项目: rtl-viewpager   文件: RtlViewPager.java
@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);
        }
    }
}
 
源代码4 项目: 365browser   文件: MaterialProgressDrawable.java
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;
    }
}
 
源代码5 项目: v2ex   文件: UIUtils.java
@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;
    }
}
 
源代码6 项目: BottomSheetPickers   文件: LocaleModel.java
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;
    }
}
 
@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);
    }
}
 
源代码8 项目: Android-Next   文件: ViewUtils.java
/**
 * 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;
    }
}
 
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);
}
 
源代码10 项目: XERUNG   文件: MaterialMultiAutoCompleteTextView.java
@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;
}
 
源代码11 项目: deltachat-android   文件: ViewUtil.java
@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);
    }
  }
}
 
源代码12 项目: android-chromium   文件: LocalizationUtils.java
/**
 * @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;
}
 
源代码13 项目: litho   文件: Layout.java
@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;
}
 
private static float getSignFromDirection(@NonNull View view) {
  return view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL ? -1f : 1f;
}
 
源代码15 项目: LB-Launcher   文件: ButtonDropTarget.java
private boolean isRtl() {
    return (getLayoutDirection() == View.LAYOUT_DIRECTION_RTL);
}
 
源代码16 项目: prayer-times-android   文件: BaseActivity.java
protected boolean isRTL() {
    Configuration config = getResources().getConfiguration();
    return config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
}
 
源代码17 项目: Transitions-Everywhere   文件: ViewUtils.java
@Override
public boolean isRtl(@NonNull View view) {
    return view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
}
 
源代码18 项目: BreadcrumbsView   文件: ViewUtils.java
/**
 * 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;
}
 
源代码19 项目: android_9.0.0_r45   文件: BidiFormatter.java
/**
 * 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);
}
 
源代码20 项目: android_9.0.0_r45   文件: Configuration.java
/**
 * 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;
}
 
 方法所在类
 同类方法