I'm working in app but the language will be Arabic even the Activity name.
To show activity name to right in RTL language, you have to change the device language to RTL
Change the Display Language:
Tap the Settings app
Tap the "Language & input" option
Tap the "Language" option
Select any RTL language [Arabic] from the list of languages.
Check more details here
I think you mean how to enable RTL support for your application?
In order to support RTL in your app, you first need to add android:supportsRtl="true" to the element in your manifest file.
If you want to force any layout to LTR then just add android:layoutDirection="ltr" to that view.
It's also recommended that you use "start" and "end" instead of "left" and "right" when designing your layouts.
Related
I am programming an Android application. This application isn't translated to any right to left language (like Arabic or Hebrew). I've noticed that right to left language people has it in English, but with right to left layout. The drawer menu is on the right instead of the left and the text is right aligned.
What is the good practice to manage this? Should I let the RTL layout because they are used to it or should I force LTR layout because the app is in English?
If you’re not supporting RTL languages you should not support RTL layouts (LTR languages looks pretty bad in RTL languages).
Just add android:supportRtl="false" attribute in your manifest's application tag.
It should solve it.
Even though false is the default value, one of your dependencies can override it to true if you don't set it explicitly.
Confirm that this is the issue by checking the final merged manifest if android:supportRtl is true.
i build new application with simple login activity with firebase when i install on phone with english language it work perfectly.
but when i change phone language to arabic it dosen't work.
all data entered was in english language.Any ideas?!!
for UI design it makes difference if your user phone is using right to left language or left to right language
if this is the case you should decide you want your app adapt changes or be fixed
for example you can use layout_marginLeft instead of using layout_marginStart
but for preferences activity you cannot change layout direction in easy way
If you want to support arabic your app should support RTL.
you need to change all your layouts where ever you are using left and right to start and end.
Also you need add textAlignment property to textviews.
I have developed an app in English language. When i change my android language to a right-to-left (later rtl) language , my app goes rtl layout but I don't want that. I want my app layout to stay left-to-right (later ltr) whether android language is ltr or rtl.
I know there is layoutdirection in a activity attributes but it's not for APIs below 17.
I'd still say to use this:
Add in styles.xml in your Base App theme style:
<item name="android:layoutDirection">ltr</item>
17+ is legitimate.
Just do this in manifest
android:supportsRtl="false"
with support rtl your layout in english is still ltr.
rtl is on only for languages how japanese and so on.
the most devices are already API 17+.
On emulator or device you can change main language, so you can use rtl or rtl layout depend on selected language.
Try to put all of your resources (layouts, strings, drawable ... etc) in rtl language folder like
layout-ar and remove default layout folder
also use values-ar, drawable-ar .... etc only
i think this will force android to read from it.
I'm using font-awesome for some of my buttons. One of them is a "back" button. On LTR languages, I want the button to be an arrow that points to the left, and on RTL, an arrow that points to the right.
Right now what I'm doing is this:
I'm holding two strings in my "values" folder
<string name="icon_back_ltr"></string>
<string name="icon_back_rtl"></string>
<color name="icon_back_color">#FFFFFF</color>
Then, I check programatically if the device language is an RTL language. If so, I modify the text on the button accordingly.
My question is, is there a better way to do it? One that does not require checking for layout direction programatically? For example, I know I can define the word "Hello" to be in English (using "values") and then to be something else in Hebrew (using "values-iw). The question is, can I define a certain string to be text A in all LTR languages and then to be text B in all RTL languages?
Define two reource driectories values-ldrtl (means "layout-direction-right-to-left") and values-ldltr (means "layout-direction-left-to-right").
Declare in your app manifest that your app supports RTL mirroring.
Specifically, add android:supportsRtl="true" to the <application> element in your manifest file and set targetSdkVersion to 17 or higher.
In Settings of my Android app, I use many of checkboxPreferences. When the locale selected is English, text appears at the Left side and Check box at the right side.
Text ------------------Checkbox
When I change locale to Arabic, I want to get this format:
Checkbox---------------Text
But it keeps the same as English locale. I don't know what to do. Can someone help me?
To take advantage of RTL layout mirroring, simply make the following changes to your app:
Declare in your app manifest that your app supports RTL mirroring. Add android:supportsRtl="true" to the element in your manifest file.
Change all of your app's "left/right" layout properties to new "start/end" equivalents.
For more details follow the link
Use RelativeLayout as the parent layout and then add layout_alignParentStart or layout_alignParentEnd attributes for Text / Checkbox views.
Please note, this only works from API v17 on.