Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identifying RTL language in Android

Is there a way to identify RTL (right-to-left) language, apart from testing language code against all RTL languages?

Since API 17+ allows several resources for RTL and LTR, I assume, there should be a way, at least from API 17.

like image 637
cyanide Avatar asked Sep 25 '13 04:09

cyanide


People also ask

How do I know if I have RTL Android?

You can check your app in RTL mode by doing one of two things. Select one of the RTL languages as your device language. Or from Developer Options in Settings , check Force RTL layout Direction .

What is RTL in Android?

android.util.LayoutDirection. A class for defining layout directions. A layout direction can be left-to-right (LTR) or right-to-left (RTL). It can also be inherited (from a parent) or deduced from the default language script of a locale.

How do I enable RTL on Android?

To force right-to-left layouts on your Android device you need to open Settings, and access the Developer options menu (if developer options aren't enabled, here's how to do it). Once you've accessed the menu, scroll down to find the “Force RTL layout direction” tab. Tap on it to activate the option, and you're done.


1 Answers

Get it from Configuration.getLayoutDirection():

Configuration config = getResources().getConfiguration(); if(config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {     //in Right To Left layout } 
like image 181
Morrison Chang Avatar answered Sep 21 '22 15:09

Morrison Chang