Reputation: 647
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?
Upvotes: 2
Views: 899
Reputation: 7040
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.
Upvotes: 4