gga
gga

Reputation: 107

In horizontal linearlayout, how to add from left to right instead of right to left

I think the source of the problem is that my phone language is right-to-left. So in Android Studio preview, when i try to use horizontal LinearLayout it shows the views im adding from left to right, but running on my phone it switches the order from right to left. How can i force Linear Layout views to add from left to right?

Upvotes: 5

Views: 1143

Answers (2)

Nikita Kurtin
Nikita Kurtin

Reputation: 6237

I would like to add that according to developer.android it's only available in API 17 and higher:

Note: To enable right-to-left layout features for your app, you must set supportsRtl to "true" and set targetSdkVersion to 17 or higher.

reference:Layout direction

for lower API (which still relevant today) it's a lit bit messy, some of issues (and solutions) discussed here: layoutDirection android pre 4.2

Upvotes: 1

Yury Fedorov
Yury Fedorov

Reputation: 14938

Try to play with android:layoutDirection parameter in your XML layout file to explicitly define the direction of your Views

EDIT

This feature is available from API 17, so you'll need to implement it differently in earlier versions.

Upvotes: 3

Related Questions