gpt4 book ai didi

android - TextView的样式和android :textAppearance attributes?有什么区别

转载 作者:IT老高 更新时间:2023-10-28 23:07:12 42 4
gpt4 key购买 nike

如果我将 TextView 定义为:

 <TextView
style="@android:style/TextAppearance.DeviceDefault.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />

和做的基本一样:

 <TextView
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />

我知道 style 是某种更广泛的限定符(即不能在 android:textAppearance 中设置所有属性),但它提出了一个问题:为什么要打扰?与 style 相比,使用 android:textAppearance 有什么优势吗?

最佳答案

来自样式和主题 https://developer.android.com/guide/topics/ui/look-and-feel/themes#textappearance

One limitation with styles is that you can apply only one style to a View. In a TextView, however, you can also specify a TextAppearance attribute which functions similarly to a style

TextAppearance allows you to define text-specific styling while leaving a View’s style available for other uses. Note, however, that if you define any text attributes directly on the View or in a style, those values would override the TextAppearance values.

关于android - TextView的样式和android :textAppearance attributes?有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38517090/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com