【发布时间】:2018-11-09 20:18:36
【问题描述】:
android:textAppearance 允许您为文本视图上的某些属性应用额外的样式层。我想知道这个功能的灵活性是否超过了它的复杂性。
- 是否出于任何技术或视觉原因需要
android:textAppearance? - 在整个项目中仅依赖
style而在布局中省略使用android:textAppearance可能会产生什么后果? - 如果样式中也省略了它怎么办?
这里有两个指南推荐使用android:textAppearance:
Styling Views on Android (Without Going Crazy)
TextAppearance 允许您将两种样式合并为一些最 常用修改的文本属性。看看你所有的风格:如何 他们中的许多人只修改文本的外观?在这些情况下,您可以 而只是修改 TextAppearance。
Best practices for happy Android resources
为确保 TextView 的外观一致,请勿在普通样式中定义任何 TextAppearance 属性,但始终在该样式的 android:textAppearance 字段上从您的库中设置 TextAppearance。
【问题讨论】:
-
从未使用过
android:textAppearance:,我还活着 :) 总是使用总线样式 -
android:textAppearance如果您需要将其设为预定义样式,则会减少您的代码。否则,请根据需要随意使用样式..
标签: android android-layout android-theme android-styles android-textattributes