List of usage examples for android.view View LAYOUT_DIRECTION_RTL
int LAYOUT_DIRECTION_RTL
To view the source code for android.view View LAYOUT_DIRECTION_RTL.
Click Source Link
From source file:com.duolingo.open.rtlviewpager.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(); }//from w ww.j a v a2 s . c o m mLayoutDirection = viewCompatLayoutDirection; if (adapter != null) { adapter.notifyDataSetChanged(); setCurrentItem(position); } } }
From source file:com.android.deskclock.widget.RtlViewPager.java
/** * Get a "RTL friendly" index. If the locale is LTR, the index is returned as is. * Otherwise it's transformed so view pager can render views using the new index for RTL. For * example, the second view will be rendered to the left of first view. * * @param index The logical index.//w w w. j av a 2 s . com */ public int getRtlAwareIndex(int index) { if (TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL) { return getAdapter().getCount() - index - 1; } return index; }
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/*from w ww.j av a 2 s .c om*/ * @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.android.messaging.util.AccessibilityUtil.java
/** * Check to see if the current layout is Right-to-Left. This check is only supported for * API 17+.// w w w .j av a 2 s . co 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.onyx.deskclock.deskclock.widget.RtlViewPager.java
/** * Get a "RTL friendly" index. If the locale is LTR, the index is returned as is. * Otherwise it's transformed so view pager can render views using the new index for RTL. For * example, the second view will be rendered to the left of first view. * * @param index The logical index.//w ww . ja v a2 s .c o m */ public int getRtlAwareIndex(int index) { if (Build.VERSION.SDK_INT >= 17) { if (TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL) { return getAdapter().getCount() - index - 1; } } else { if (TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL) { return getAdapter().getCount() - index - 1; } } return index; }
From source file:com.appsimobile.appsii.module.home.SunriseDrawable.java
public SunriseDrawable(Context context) { mContext = context;//from w w w. j av a2 s . c o m Resources res = context.getResources(); final TypedArray a = context.obtainStyledAttributes(new int[] { R.attr.colorPrimary, R.attr.colorAccent, R.attr.colorPrimaryDark, R.attr.appsiHomeWidgetPrimaryColor, }); int primaryColor = a.getColor(0, Color.BLACK); int accentColor = a.getColor(1, Color.BLACK); int primaryColorDark = a.getColor(2, Color.BLACK); int textColor = a.getColor(3, Color.BLACK); a.recycle(); mIsRtl = TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL; float density = res.getDisplayMetrics().density; int sunBounds = (int) (density * 16); mTopOffset = (int) (density * 12); mLeftOffset = (int) (density * 24); mRightOffset = (int) (density * 24); mBottomOffset = (int) (density * 24); mDotRadius = (int) (density * 2); mSunImage = mContext.getResources().getDrawable(R.drawable.ic_weather_clear); mSunImage.setBounds(0, 0, sunBounds, sunBounds); mArcPaint = new Paint(); mArcPaint.setColor(primaryColorDark); mArcPaint.setStyle(Paint.Style.STROKE); mArcPaint.setAntiAlias(true); mArcFillPaint = new Paint(); mArcFillPaint.setColor(primaryColor); mArcFillPaint.setAlpha(64); mArcFillPaint.setStyle(Paint.Style.FILL); mArcFillPaint.setAntiAlias(true); mLinePaint = new Paint(); mLinePaint.setColor(textColor); mLinePaint.setAlpha(128); mLinePaint.setStyle(Paint.Style.STROKE); mDotPaint = new Paint(); mDotPaint.setStyle(Paint.Style.FILL); mDotPaint.setColor(primaryColorDark); mDotPaint.setAntiAlias(true); }
From source file:barqsoft.footballscores.utils.Utility.java
/** * Check if we are on a device in RTL mode * http://stackoverflow.com/questions/14402329/disable-actionbar-rtl-direction * * @return boolean//from w w w . ja v a 2 s . c om */ public static boolean isRtlMode(Context context) { boolean rtl = false; // check direction depending on the api level device supports if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { // if device supports API 17 or higher we can use getLayoutDirection Configuration config = context.getResources().getConfiguration(); if (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { rtl = true; } } else { // else get language codes Set<String> lang = new HashSet<>(); lang.add("ar"); lang.add("dv"); lang.add("fa"); lang.add("ha"); lang.add("he"); lang.add("iw"); lang.add("ji"); lang.add("ps"); lang.add("ur"); lang.add("yi"); Set<String> RTL = Collections.unmodifiableSet(lang); Locale locale = Locale.getDefault(); rtl = RTL.contains(locale.getLanguage()); } return rtl; }
From source file:org.mozilla.focus.browser.LocalizedContent.java
private static void putLayoutDirectionIntoMap(WebView webView, Map<String, String> substitutionMap) { ViewCompat.setLayoutDirection(webView, View.LAYOUT_DIRECTION_LOCALE); final int layoutDirection = ViewCompat.getLayoutDirection(webView); final String direction; if (layoutDirection == View.LAYOUT_DIRECTION_LTR) { direction = "ltr"; } else if (layoutDirection == View.LAYOUT_DIRECTION_RTL) { direction = "rtl"; } else {/*from w w w . j av a2 s. co m*/ direction = "auto"; } substitutionMap.put("%dir%", direction); }
From source file:org.catrobat.paintroid.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { initLocaleConfiguration();/*ww w . j a v a 2 s . co m*/ Configuration config = getApplicationContext().getResources().getConfiguration(); PaintroidApplication.isRTL = (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL); ColorPickerDialog.init(this); IndeterminateProgressDialog.init(this); super.onCreate(savedInstanceState); setContentView(R.layout.main); initActionBar(); mInputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); PaintroidApplication.catroidPicturePath = null; String catroidPicturePath = null; Bundle extras = getIntent().getExtras(); if (extras != null) { catroidPicturePath = extras.getString(getString(R.string.extra_picture_path_catroid)); Log.d(PaintroidApplication.TAG, "catroidPicturePath: " + catroidPicturePath); } if (catroidPicturePath != null) { PaintroidApplication.openedFromCatroid = true; if (!catroidPicturePath.equals("")) { PaintroidApplication.catroidPicturePath = catroidPicturePath; PaintroidApplication.scaleImage = false; } ActionBar supportActionBar = getSupportActionBar(); if (supportActionBar != null) { supportActionBar.setDisplayHomeAsUpEnabled(true); supportActionBar.setDisplayShowHomeEnabled(true); } } else { PaintroidApplication.openedFromCatroid = false; } PaintroidApplication.orientation = getResources().getConfiguration().orientation; PaintroidApplication.drawingSurface = (DrawingSurface) findViewById(R.id.drawingSurfaceView); PaintroidApplication.perspective = new Perspective(PaintroidApplication.drawingSurface.getHolder()); mDrawingSurfaceListener = new DrawingSurfaceListener(); BrushPickerView.init(this); mBottomBar = new BottomBar(this); mTopBar = new TopBar(this, PaintroidApplication.openedFromCatroid); mLayerSideNav = (NavigationView) findViewById(R.id.nav_view_layer); mLayersAdapter = new LayersAdapter(this, PaintroidApplication.openedFromCatroid, PaintroidApplication.drawingSurface.getBitmapCopy()); int colorPickerBackgroundColor = PaintroidApplication.colorPickerInitialColor; ColorPickerDialog.getInstance().setInitialColor(colorPickerBackgroundColor); PaintroidApplication.drawingSurface.setOnTouchListener(mDrawingSurfaceListener); if (PaintroidApplication.openedFromCatroid && catroidPicturePath != null && catroidPicturePath.length() > 0) { initializeWhenOpenedFromCatroid(); loadBitmapFromUriAndRun(Uri.fromFile(new File(catroidPicturePath)), new RunnableWithBitmap() { @Override public void run(Bitmap bitmap) { if (!bitmap.hasAlpha()) { bitmap.setHasAlpha(true); } handleAndAssignImage(bitmap); } private void handleAndAssignImage(Bitmap bitmap) { Command command = new LoadCommand(bitmap); PaintroidApplication.commandManager.commitCommandToLayer( new LayerCommand(LayerListener.getInstance().getCurrentLayer()), command); } }); } else if (PaintroidApplication.openedFromCatroid) { initializeWhenOpenedFromCatroid(); } else { initialiseNewBitmap(); } if (PaintroidApplication.openedFromCatroid == false) LayerListener.init(this, mLayerSideNav, PaintroidApplication.drawingSurface.getBitmapCopy(), false); if (!PaintroidApplication.commandManager.isCommandManagerInitialized() || PaintroidApplication.openedFromCatroid) initCommandManager(); initNavigationDrawer(); initKeyboardIsShownListener(); }
From source file:com.jaredrummler.materialspinner.MaterialSpinner.java
private void init(Context context, AttributeSet attrs) { TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MaterialSpinner); int defaultColor = getTextColors().getDefaultColor(); backgroundColor = typedArray.getColor(R.styleable.MaterialSpinner_ms_background_color, Color.WHITE); textColor = typedArray.getColor(R.styleable.MaterialSpinner_ms_text_color, defaultColor); arrowColor = typedArray.getColor(R.styleable.MaterialSpinner_ms_arrow_tint, textColor); hideArrow = typedArray.getBoolean(R.styleable.MaterialSpinner_ms_hide_arrow, false); typedArray.recycle();/*w ww. ja v a 2 s . com*/ setGravity(Gravity.CENTER_VERTICAL | Gravity.START); boolean rtl = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { Configuration config = getResources().getConfiguration(); rtl = config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; if (rtl) { setLayoutDirection(View.LAYOUT_DIRECTION_RTL); setTextDirection(View.TEXT_DIRECTION_RTL); } } Resources resources = getResources(); int left, right, bottom, top; left = right = bottom = top = resources.getDimensionPixelSize(R.dimen.ms__padding_top); if (rtl) { right = resources.getDimensionPixelSize(R.dimen.ms__padding_left); } else { left = resources.getDimensionPixelSize(R.dimen.ms__padding_left); } setClickable(true); setPadding(left, top, right, bottom); setBackgroundResource(R.drawable.ms__selector); if (!hideArrow) { arrowDrawable = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ms__arrow)); DrawableCompat.setTint(arrowDrawable, arrowColor); if (rtl) { setCompoundDrawablesWithIntrinsicBounds(arrowDrawable, null, null, null); } else { setCompoundDrawablesWithIntrinsicBounds(null, null, arrowDrawable, null); } } listView = new ListView(context); listView.setId(getId()); listView.setDivider(null); listView.setItemsCanFocus(true); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position >= selectedIndex && position < adapter.getCount()) { position++; } selectedIndex = position; nothingSelected = false; Object item = adapter.get(position); adapter.notifyItemSelected(position); setText(item.toString()); collapse(); if (onItemSelectedListener != null) { //noinspection unchecked onItemSelectedListener.onItemSelected(MaterialSpinner.this, position, id, item); } } }); popupWindow = new PopupWindow(context); popupWindow.setContentView(listView); popupWindow.setOutsideTouchable(true); popupWindow.setFocusable(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { popupWindow.setElevation(16); popupWindow.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.ms__drawable)); } else { popupWindow.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.ms__drop_down_shadow)); } if (backgroundColor != Color.WHITE) { // default color is white setBackgroundColor(backgroundColor); } if (textColor != defaultColor) { setTextColor(textColor); } popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { if (nothingSelected && onNothingSelectedListener != null) { onNothingSelectedListener.onNothingSelected(MaterialSpinner.this); } if (!hideArrow) { animateArrow(false); } } }); }