根据选择的语言进行 Android 布局

发布于 2024-12-07 03:29:55 字数 287 浏览 5 评论 0原文

我想知道是否有任何好主意如何根据所选的应用程序语言切换布局 - 例如在从左到右布局和从右到左布局之间切换。有不同的图像或书面文字,当然还有位置。

我认为使用应用程序中指示当前选择的语言的私有成员来执行此操作。根据这个参数我可以选择相关的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱殇璃 2024-12-14 03:29:55

对于 valuesdrawable,您可以添加文件夹,例如用于法语的 values-fr 或用于日语的 values-ja-fr 表示如果您的手机设置为法语本地化,则应用程序将使用名称中添加了 -fr 的任何文件夹。我猜这也适用于 layout 文件夹。

您可以此处了解本地化

For values and drawable you can add folders like values-fr for French or values-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 the layout folder aswell.

You can read about Localization here .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文