Java Examples for android.view.View.LAYOUT_DIRECTION_RTL
The following java examples will help you to understand the usage of android.view.View.LAYOUT_DIRECTION_RTL. These source code samples are taken from different open source projects.
Example 1
| Project: edx-app-android-master File: IconDrawable.java View source code |
// Since the auto-mirrored state is only set to true if the SDK
// version supports it, we don't need an explicit check for that
// before calling getLayoutDirection().
@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;
}Example 2
| Project: Lets-Vote-master File: Dialog.java View source code |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public void onRtlPropertiesChanged(int layoutDirection) {
boolean rtl = layoutDirection == LAYOUT_DIRECTION_RTL;
if (mIsRtl != rtl) {
mIsRtl = rtl;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
int direction = mIsRtl ? TEXT_DIRECTION_RTL : TEXT_DIRECTION_LTR;
mTitle.setTextDirection(direction);
mPositiveAction.setTextDirection(direction);
mNegativeAction.setTextDirection(direction);
mNeutralAction.setTextDirection(direction);
}
requestLayout();
}
}Example 3
| Project: AndroidChromium-master File: UrlBar.java View source code |
/**
* If the direction of the URL has changed, update mUrlDirection and notify the
* UrlDirectionListeners.
*/
private void updateUrlDirection() {
Layout layout = getLayout();
if (layout == null)
return;
int urlDirection;
if (length() == 0) {
urlDirection = LAYOUT_DIRECTION_LOCALE;
} else if (layout.getParagraphDirection(0) == Layout.DIR_LEFT_TO_RIGHT) {
urlDirection = LAYOUT_DIRECTION_LTR;
} else {
urlDirection = LAYOUT_DIRECTION_RTL;
}
if (urlDirection != mUrlDirection) {
mUrlDirection = urlDirection;
if (mUrlDirectionListener != null) {
mUrlDirectionListener.onUrlDirectionChanged(urlDirection);
}
}
}Example 4
| Project: cnAndroidDocs-master File: TextUtils.java View source code |
/**
* 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
*/
public static int getLayoutDirectionFromLocale(Locale locale) {
if (locale != null && !locale.equals(Locale.ROOT)) {
final String scriptSubtag = ICU.getScript(ICU.addLikelySubtags(locale.toString()));
if (scriptSubtag == null)
return getLayoutDirectionFromFirstChar(locale);
if (scriptSubtag.equalsIgnoreCase(ARAB_SCRIPT_SUBTAG) || scriptSubtag.equalsIgnoreCase(HEBR_SCRIPT_SUBTAG)) {
return View.LAYOUT_DIRECTION_RTL;
}
}
return View.LAYOUT_DIRECTION_LTR;
}Example 5
| Project: Android-Json-Parsing-Code-Sample-master File: Dialog.java View source code |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public void onRtlPropertiesChanged(int layoutDirection) {
boolean rtl = layoutDirection == LAYOUT_DIRECTION_RTL;
if (mIsRtl != rtl) {
mIsRtl = rtl;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
int direction = mIsRtl ? TEXT_DIRECTION_RTL : TEXT_DIRECTION_LTR;
mTitle.setTextDirection(direction);
mPositiveAction.setTextDirection(direction);
mNegativeAction.setTextDirection(direction);
mNeutralAction.setTextDirection(direction);
}
requestLayout();
}
}Example 6
| Project: platform_frameworks_base-master File: TextUtils.java View source code |
/**
* 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
*/
public static int getLayoutDirectionFromLocale(Locale locale) {
return ((locale != null && !locale.equals(Locale.ROOT) && ULocale.forLocale(locale).isRightToLeft()) || // If forcing into RTL layout mode, return RTL as default
SystemProperties.getBoolean(Settings.Global.DEVELOPMENT_FORCE_RTL, false)) ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR;
}Example 7
| Project: android_frameworks_base-master File: TextUtils.java View source code |
/**
* 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
*/
public static int getLayoutDirectionFromLocale(Locale locale) {
return ((locale != null && !locale.equals(Locale.ROOT) && ULocale.forLocale(locale).isRightToLeft()) || // If forcing into RTL layout mode, return RTL as default
SystemProperties.getBoolean(Settings.Global.DEVELOPMENT_FORCE_RTL, false)) ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR;
}Example 8
| Project: android-sdk-sources-for-api-level-23-master File: TextUtils.java View source code |
/**
* 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
*/
public static int getLayoutDirectionFromLocale(Locale locale) {
if (locale != null && !locale.equals(Locale.ROOT)) {
final String scriptSubtag = ICU.addLikelySubtags(locale).getScript();
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;
}Example 9
| Project: property-db-master File: TextUtils.java View source code |
/**
* 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
*/
public static int getLayoutDirectionFromLocale(Locale locale) {
if (locale != null && !locale.equals(Locale.ROOT)) {
final String scriptSubtag = ICU.getScript(ICU.addLikelySubtags(locale.toString()));
if (scriptSubtag == null)
return getLayoutDirectionFromFirstChar(locale);
if (scriptSubtag.equalsIgnoreCase(ARAB_SCRIPT_SUBTAG) || scriptSubtag.equalsIgnoreCase(HEBR_SCRIPT_SUBTAG)) {
return View.LAYOUT_DIRECTION_RTL;
}
}
return View.LAYOUT_DIRECTION_LTR;
}Example 10
| Project: assertj-android-master File: AbstractViewAssert.java View source code |
@TargetApi(JELLY_BEAN_MR1)
public static String layoutDirectionToString(@ViewLayoutDirection int direction) {
return buildNamedValueString(direction).value(LAYOUT_DIRECTION_RTL, "right_to_left").value(LAYOUT_DIRECTION_LTR, "left_to_right").value(LAYOUT_DIRECTION_INHERIT, "inherit").value(LAYOUT_DIRECTION_LOCALE, "locale").get();
}