Elyas Hadizadeh Elyas Hadizadeh - 2 months ago 14
Android Question

Android: Right-To-Left or Left-To-Right layout design based on location

I'd like to have different

layout
design based on
location
. actually I know we can have different layout based on mobile device size.

As you know Android has very good feature that you can inflate all texts in your application based on location which is called Localization.

I am looking for a kind of similar feature that force my android app to inflate suitable layout design based on location.

In Persian and Arabic, the orientation of components is better to be
Right-To-Left
, although it is possible by designing exact wanted layout, but i don't know how to make it international because regardless of size, I need to have different layout design orientation based on user location, like USA, Germany, Iran and etc.

Is there any easy and automatic way to change layout orientation from
left-to-right
to
right-to-left
based on user location? I've checked similar question in stackoverflow, but that solution is not my aim and goal.

thank you :-)

Answer

You can use layout subfolders to provide different layouts depending on language direction. (layout-ldrtl).

Also You can provide different layouts depending on language (layout-ar in Your case).

In that case layouts that contained in simple layout folder will be defaults.

More info You can find in developer site