根据选择的语言进行 Android 布局
我想知道是否有任何好主意如何根据所选的应用程序语言切换布局 - 例如在从左到右布局和从右到左布局之间切换。有不同的图像或书面文字,当然还有位置。
我认为使用应用程序中指示当前选择的语言的私有成员来执行此操作。根据这个参数我可以选择相关的XML和文本等。 实际上,我可能会创建一些 LayoutFactory 类,尽管我并不认为它是必需的。
但必须创建相关的布局 XML。 是否有任何选项可以将子目录放在布局下? 或者我应该将文件命名为 en_.xml 和 he_.xml 等?
I would like to know if there is any good idea how to switch layouts according to application language selected - e.g. switch between left-to-right layout and right-to-left layout. Have different images or written text and ofcourse the position.
I thought doing it using a private member in the application that indicates the current language selected. According to this parameter I can choose the related XML and text etc.
Actualy I might create some LayoutFactory class, although I don't really think it is required.
But will have to create the realted layout XMLs.
Is there any option to put subdirectories under he layout?
Or should I name the files like en_.xml and he_.xml etc?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于
values
和drawable
,您可以添加文件夹,例如用于法语的values-fr
或用于日语的values-ja
。-fr
表示如果您的手机设置为法语本地化,则应用程序将使用名称中添加了-fr
的任何文件夹。我猜这也适用于layout
文件夹。您可以此处了解本地化。
For
values
anddrawable
you can add folders likevalues-fr
for French orvalues-ja
for Japanese. The-fr
indicates that if your phone is set to French localization the app will use any folder that has the-fr
added to its name. I'm guessing this goes for thelayout
folder aswell.You can read about Localization here .