Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Language Specific layout for android

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

like image 846
Bora Avatar asked Sep 05 '13 05:09

Bora


People also ask

Can I change the language of a single app Android?

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.


2 Answers

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.

like image 64
GrIsHu Avatar answered Oct 26 '22 18:10

GrIsHu


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.

like image 35
Renjith Avatar answered Oct 26 '22 17:10

Renjith