I know that we can display multiple languages support for our android application with different values folder example values-en , values-ar.
My question is can we change our layout style when there is change of language.
As in English every thing starts form "left -to right" however Arabic is just apposite of it . so is it possible to place a image on left when language selected is English and Change the layout when language changes to Arabic
Change the language setting for a specific app On your Android phone, open your Settings app. App languages. Select the app you want to change. Choose a language.
The layout direction of your application. ldrtl
means "layout-direction-right-to-left"
. ldltr
means "layout-direction-left-to-right"
and is the default implicit value.
This can apply to any resource such as layouts, drawables
, or values
.
For example, if you want to provide some specific layout for the Arabic language
and some generic layout for any other "right-to-left" language (like Persian or Hebrew) then you would have:
res/
layout/
main.xml (Default layout)
layout-ar/
main.xml (Specific layout for Arabic)
layout-ldrtl/
main.xml (Any "right-to-left" language, except
for Arabic, because the "ar" language qualifier
has a higher precedence.)
Note: To enable right-to-left
layout features for your app, you must set supportsRtl
to "true"
and set targetSdkVersion to 17 or higher.
can we change our layout style when there is change of language.
Yes. You can provide different layouts according to the language user chooses. This is clearly described in the Providing Resources documentation.
Infact a specific layout qualifier is provided for supporting right-to-left-directed languages called res/layout-ldrtl
.
P.S: This attribute is only supported from API 17.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With