Returns true if view's layout direction is right-to-left. - Android User Interface

Android examples for User Interface:Layout

Description

Returns true if view's layout direction is right-to-left.

Demo Code

// Copyright 2013 The Chromium Authors. All rights reserved.
//package com.java2s;

import android.os.Build;
import android.view.View;

public class Main {
    /**/*from w  ww  .j av a 2  s.co  m*/
     * Returns true if view's layout direction is right-to-left.
     *
     * @param view the View whose layout is being considered
     */
    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;
        }
    }
}

Related Tutorials