Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Developing a right-to-left Android application

I'm working on a relatively simple Android app. I want it to have an English version as well as a Hebrew version.

I have an activity all laid out in English, and I want to create the Hebrew resources. I couldn't find any easy way to do it. The only way I found was to take my layout/activity.xml file, put it in layout-iw/activity.xml and manually change everything so it appears right to left.

I need to reverse the order of all elements in any horizontally oriented container (all the columns in <TableRow>s, all the elements in horizontal <LinearLayout>s, etc...). I need to switch all layout_marginLefts with layout_marginRights, and of course - make all left-aligned controls right-aligned.

This is tedious, especially if I think about modifying the activity at some point - I'll need to modify the resources twice, and that alone gives me a headache.

There has to be an easier way.

like image 445
zmbq Avatar asked Nov 03 '11 22:11

zmbq


1 Answers

Unfortunately you are correct this is exactly what you will have to do. I would suggest using styles to format any elements where padding or margins need to change do to a switch from left to right text. If you construct your styles right it should limit the amount of line by line changes needed in individual layout files. However I do realize this is a case where hind-site is 20/20.

like image 149
riotopsys Avatar answered Sep 22 '22 08:09

riotopsys