如何在样式xml中包含工具名称空间

Art*_*jia 9 xml android android-layout

我想能够使用

tools:text="Text"
Run Code Online (Sandbox Code Playgroud)

在style.xml文件中,这种方式不会复制tools:我使用该样式的所有布局中的文本。

我已经尝试过:

<item name="text">@string/text</item>
Run Code Online (Sandbox Code Playgroud)

但是当出现时,编辑器不会显示文本。

谢谢你的帮助!

Ben*_* P. 8

根据文档:https : //developer.android.com/studio/write/tool-attributes.html#design-time_view_attributes

tools: 代替 android:

适用于: <View>

使用者:Android Studio布局编辑器

不幸的是,这意味着您不能tools:text<style>元素内部使用。