Android的改变语言配置搅乱布局 [英] Android changing language configuration messes up layout

查看:962
本文介绍了Android的改变语言配置搅乱布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想希伯来语支持添加到我的Andr​​oid应用程序。
我不得不版本更改为2.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)

和这里的混乱之一:

这两个XML布局是相同的,但希伯来布局有安卓重力=权利关于textviews设置

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

下面是code键更改区域设置和配置。 '的setContentView'是在此之后正确调用。

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());

如果我已经问......有什么办法来设置RTL阅读的Andr​​oid?正如你所看到的,希伯来布局搞砸文本RTL了。

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.

我曾尝试使用RTL UNI code字符\\ u200f,但你可以看到它并没有在所有帮助....

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

任何想法?谢谢你。

推荐答案

我不得不在清单补充一点:

I had to add this in the manifest:

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

和它的工作。

这篇关于Android的改变语言配置搅乱布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆