android - 如何在样式 xml 中包含工具命名空间

标签 android xml android-layout

我希望能够使用

tools:text="Text"

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

我已经试过了:

<item name="text">@string/text</item>

但是当存在时,编辑器不显示文本。

感谢您的帮助!

最佳答案

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

tools: instead of android:

Intended for: <View>

Used by: Android Studio layout editor

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

关于android - 如何在样式 xml 中包含工具命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48851616/

相关文章:

android - TextView 失败

java - 约束布局不适合不同设备

android - TextViews不在约束布局中移至“开始”位置

java - 通过 dom4j XPath 奇怪的行为解析带有 namespace 的 xml

android - 视频在播放前闪烁黑色 (ExoPlayer)

android - 为什么应用程序有时会在 killProcess 上重新启动?

具有固定日期和重复性的 Android 闹钟管理器

android - WhatsApp 如何设计使用 edittext UI 发送图像预览

android - clearColorFilter() 不适用于 android 2.3

android - Viewpager 没有得到最后一项