如果没有可用的翻译,则禁用 RTL

App*_*evo 5 android android-layout right-to-left

我有应用程序中的阿拉伯语翻译。该应用程序还支持 RTL 布局。当用户使用阿拉伯语时,一切看起来都很好。问题是,当我将 local 更改为 eq Persian(他们使用 RTL)但我不提供这种语言的翻译时,我的布局看起来一团糟。

如果当前本地没有可用的翻译,如何禁用 RTL?

Pre*_*ens 0

尝试这样的事情。我自己没有尝试过,但正在思考这个问题。

Configuration config = context.getResources().getConfiguration();
   if (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
      //if you do not have a string defined here you can disable it here
        config.setLayoutDirection(View.LAYOUT_DIRECTION_LTR);

    }
Run Code Online (Sandbox Code Playgroud)