我做了一个 应用管理器 另类应用程序,我想补充翻译RTL(从右到左)的语言。
I've made an "app manager" alternative app, and I wish to add translation for RTL (right to left) languages.
因为我知道,由于某些Android版本,事情就翻转,让单词和句子排列正确,我决定先切换到这样的语言,然后继续翻译
Since I know that as of certain Android version, things got flipped to let words and sentences align correctly, I decided to first switch to such a language and then continue with the translation
在切换到RTL语言(希伯来语在我的情况),我发现,在操作栏中的向上按钮有<图像水平翻转:
After switching to an RTL language (Hebrew in my case), I've found out that the action bar's up button has the "<" image flipped horizontally:
所以,现在它显示>来代替。
So now it shows ">" instead.
如何解决呢?它没有意义的,这样看...
How do I fix it? It doesn't make sense to see it this way...
那么,你可以访问动作条
向上的启示,通过调用资源.getIdentifier
和 View.findViewById
。之后,你可以旋转它。
Well, you can access that ActionBar
"up" affordance by calling Resources.getIdentifier
and View.findViewById
. After that you could rotate it.
final int upId = getResources().getIdentifier("up", "id", "android");
final View up = findViewById(upId);
// Call this to just rotate the icon 180°
if (getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
up.setRotation(180f);
}