How to make my application independent phone language - android

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.

Related

How to manage RTL languages phones in English application

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.

Is there a way to change the layout direction for my app in android

I need to change the layout direction inside my app, from LTR to RTL and vise versa, I looked there is no clear solution online, is this process simple or not, I mean it must be property inside the app you can change this property easily for all the layouts in your app, any ideas?
Note: I want to change the language and the layout just inside my app.
Put your device in RTL mode, you can do this in the develop settings (Force RTL layout direction).
You should ensure that all your layouts don't use "left" and "right" properties, e.g layout_marginLeft, instead they should use layout_marginStart and layout_marginEnd.
This will mean that when run on device that's set to read right to left (e.g arabic), all the layouts will mirror correctly.
If you don't want to change the whole device into RTL, paste this in the onCreate method of every activity in your app (paste it before super and before you inflate the content view.
Java: getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
Kotlin: window.decorView.layoutDirection = View.LAYOUT_DIRECTION_RTL
(I don't believe you'll need to add this to every fragment, only activities).
You can force RTL like this
window.decorView.layoutDirection = View.LAYOUT_DIRECTION_RTL
You can also set it to LAYOUT_DIRECTION_LTR for left-to-right layout direction

Make Android layouts independent of system locale?

I am using an android library (leanback library for android tv) and want to set my app layouts independent of the system locale.
In other words, as all of my users use right to left language and layout, I want to prevent rendering layout in "Left to Right" mode even if system language is on a LTR lang like english.
So can I set a flag or do other stuff to make the app ignore system locale totally?
EDIT : Thanks to Andres comment, I followed this link and it works perfectly.
Use android:layoutDirection="rtl" for your layout's root and android:layout_gravity="start" for child views.
This way you force your layout to be right to left and all child views appear on the right side of the parent (start means right in rtl direction).

Arabic Text Issue In Android

I am working on an application that will work on Android WebView. I enabled the selection and copy for this view. In some devices that support Arabic, When I paste the copied text from WebView in any EditText view, It shows me the reserve text. but In some cases it shows me the correct form.
Could any one please help me to show in correct form in all devices ? :-/
I have red all threads that depend on supporting Arabic and Farsi Text, but I can not reach my purpose.
Thanks in advance :)
You can pass your copied text to FarsiLibrary. It will analyses your text letters and justify them according to their possible 4 states (Initial, Middle, End, Isolated) :
Initial like 'ن' in 'نازک'
Middle like 'ن' in 'هنر'
End like 'ن' in 'وطن'
Isolated like 'ن' in 'ایران'
Android has Added support for RTL in Native widgets(i.e TextView , EditText) . so if u run the app onward 4.2 u will get RTL feature automatically ,
http://android-developers.blogspot.com.es/2013/03/native-rtl-support-in-android-42.html
You can create different versions of the layouts for different API versions.
As you can read here: http://developer.android.com/guide/topics/resources/providing-resources.html you can have say the normal folder (/res/layout/) with the layout for old devices and then another one for the ones that support it: /res/layout-11/
The layout inside layout-v11 will only be applied on devices with android 3.0 and over.

Developing a right-to-left Android application

I'm working on a relatively simple Android app. I want it to have an English version as well as a Hebrew version.
I have an activity all laid out in English, and I want to create the Hebrew resources. I couldn't find any easy way to do it. The only way I found was to take my layout/activity.xml file, put it in layout-iw/activity.xml and manually change everything so it appears right to left.
I need to reverse the order of all elements in any horizontally oriented container (all the columns in <TableRow>s, all the elements in horizontal <LinearLayout>s, etc...). I need to switch all layout_marginLefts with layout_marginRights, and of course - make all left-aligned controls right-aligned.
This is tedious, especially if I think about modifying the activity at some point - I'll need to modify the resources twice, and that alone gives me a headache.
There has to be an easier way.
Unfortunately you are correct this is exactly what you will have to do.
I would suggest using styles to format any elements where padding or margins need to change do to a switch from left to right text. If you construct your styles right it should limit the amount of line by line changes needed in individual layout files. However I do realize this is a case where hind-site is 20/20.

Categories

Resources