2

So I'm trying to add hebrew support to my android app. I had to change the version to 2.2 so it would have built-in hebrew fonts. Some things in the layout has messed up but I fixed them.

But one thing has left - for some reason, when forcing hebrew locale, ONE of my layouts gets messed up... No idea why. And even when using the SAME layout for both locales (English and Hebrew) it's still get messed up this way (But the texts still stick to the left)

Here is the normal layout (Graph is taking full screen)

Normal layout

And here is the messed one:

Messed up layout

Both xml layouts are the same, but the hebrew layout has 'android:gravity="right"' set on the textviews.

Here is the code to change locale and configuration. 'setContentView' is called right after this.

        Locale locale = new Locale("iw");
        Locale.setDefault(locale);
        Configuration config = new Configuration();
        config.locale = locale;
        getBaseContext().getResources().updateConfiguration(config,  getBaseContext().getResources().getDisplayMetrics());

And if I'm already asking... Is there any way to set rtl reading in android? As you can see, the hebrew layout has messed up the text rtl too.

I have tried to use the rtl unicode character \u200f, but as you can see it didn't help at all....

Any ideas? Thanks.

j0k
  • 22,600
  • 28
  • 79
  • 90
Jong
  • 9,045
  • 3
  • 34
  • 66
  • I have found out what really happens there - apperantly, each time 'onCreate' is called from any activity, somethings gets messed up with the display and it gets SMALLER and smaller. in the end, it reached to a point where NOTHING is shown, and then it crashed.... Probably the AVD isn't good, Ill change it. – Jong Sep 02 '11 at 21:10
  • And no, different AVD version didnt change it, each time an acitivity in my app calls its 'onCreate' where we use this code snippet I have posted above, it gets smaller and smaller... Why is that? – Jong Sep 02 '11 at 21:19
  • 3
    You are probably overwriting other values in the configuration with values that get set by the default constructor. Try to get the current configuration via `getBaseContext().getResources().getConfiguration()` and edit this instead of creating a new config via `new Configuration()`. –  Sep 02 '11 at 21:35
  • It did not help. Nor adding `android:configChanges="locale"` in the manifest. – Jong Sep 03 '11 at 07:47

1 Answers1

1

I had to add this in the manifest:

  <supports-screens
    android:smallScreens="true"
    android:normalScreens="true"
    android:largeScreens="true"
    android:anyDensity="true"
    />

And it worked.

Jong
  • 9,045
  • 3
  • 34
  • 66