Example usage for android.view View getLayoutDirection

List of usage examples for android.view View getLayoutDirection

Introduction

In this page you can find the example usage for android.view View getLayoutDirection.

Prototype

@ViewDebug.ExportedProperty(category = "layout", mapping = {
        @ViewDebug.IntToString(from = LAYOUT_DIRECTION_LTR, to = "RESOLVED_DIRECTION_LTR"),
        @ViewDebug.IntToString(from = LAYOUT_DIRECTION_RTL, to = "RESOLVED_DIRECTION_RTL") })
@ResolvedLayoutDir
public int getLayoutDirection() 

Source Link

Document

Returns the resolved layout direction for this view.

Usage

From source file:Main.java

public static int getLayoutDirection(View v) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return v.getLayoutDirection();
    }/*w  ww.j  av a  2 s .c om*/

    return View.LAYOUT_DIRECTION_LTR;
}

From source file:Main.java

/**
 * 23      * Returns true if view's layout direction is right-to-left.
 * 24      *//from   w w w  .j  av a  2  s .c  o  m
 * 25      * @param view the View whose layout is being considered
 * 26
 */
@SuppressLint("NewApi")
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;
    }
}

From source file:Main.java

/**
 * Determines whether the given view has RTL layout.
 *///from  w  w  w.  ja  v  a  2s  . c  o m
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static boolean isLayoutRtl(View view) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return View.LAYOUT_DIRECTION_RTL == view.getLayoutDirection();
    } else {
        return false;
    }
}

From source file:Main.java

/**
 * Returns true if view's layout direction is right-to-left.
 *
 * @param view the View whose layout is being considered
 *///from   w w  w  .  ja  va  2  s.co  m
public static boolean isLayoutRtl(View view) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
    } else {
        // All layouts are LTR before JB MR1.
        return false;
    }
}

From source file:Main.java

/**
 * Determines whether the given view has RTL layout.
 *//*  w  w w. j  av a 2s  .c  o m*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static boolean isLayoutRtl(View view) {
    return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1
            && View.LAYOUT_DIRECTION_RTL == view.getLayoutDirection();
}

From source file:com.android.messaging.util.AccessibilityUtil.java

/**
 * Check to see if the current layout is Right-to-Left. This check is only supported for
 * API 17+./* ww  w. ja  va  2s  .c  o  m*/
 * For earlier versions, this method will just return false.
 * @return boolean Boolean indicating whether the currently locale is RTL.
 */
public static boolean isLayoutRtl(final View view) {
    if (OsUtil.isAtLeastJB_MR1()) {
        return View.LAYOUT_DIRECTION_RTL == view.getLayoutDirection();
    } else {
        return false;
    }
}

From source file:com.silentcircle.common.util.ViewUtil.java

/**
 * Returns a boolean indicating whether or not the view's layout direction is RTL
 *
 * @param view - A valid view/*  w  w w. ja v  a 2s.  co m*/
 * @return True if the view's layout direction is RTL
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static boolean isViewLayoutRtl(View view) {
    return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
            && (view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL);
}

From source file:com.cyanogenmod.filemanager.ui.widgets.DrawerLayout.java

boolean isDrawerView(View child) {
    final int gravity = ((LayoutParams) child.getLayoutParams()).gravity;
    final int absGravity = Gravity.getAbsoluteGravity(gravity, child.getLayoutDirection());
    return (absGravity & (Gravity.LEFT | Gravity.RIGHT)) != 0;
}