首页 > 解决方案 > 是否可以将包含 %1$s 或 @string/some_string 的字符串资源包含在布局 XML 中

问题描述

在 Android Studio 中,有没有办法在布局 XML 文件中使用%1$s或嵌套字符串资源?strings.xml

例如:

字符串.xml

<string name="help_menu_title">Help</string>
<string name="help_tooltip">Please see \'%1$s\' menu for more information.</string>

my_layout.xml

<textview
    text="@string/help_tooltip" />

或者

字符串.xml

<string name="help_menu_title">Help</string>
<string name="help_tooltip">Please see \'@string/help_menu_title\' menu for more information.</string>

my_layout.xml

<textview
    text="@string/help_tooltip" />

还是必须textview重新分配文本String.format以包含“嵌套”字符串?

标签: androidxmlandroid-studioandroid-layout

解决方案


推荐阅读