每https://material.io/develop/android/theming/typography/,我一直在通过修改textAppearanceX属性来自定义应用的样式。是否有人知道要自定义哪个属性来设置应用程序的小吃店的样式或该文件的记录位置?
谢谢。
使用材料组件库,您可以通过应用程序主题自定义文本和按钮所使用的textAppearance
:
只需使用snackbarButtonStyle
和snackbarTextViewStyle
属性在应用程序中定义globally:
<style name="AppTheme" parent="Theme.MaterialComponents.*">
<!-- Style to use for action button within a Snackbar in this theme. -->
<item name="snackbarButtonStyle">@style/Custom.TextButton.Snackbar</item>
<!-- Style to use for message text within a Snackbar in this theme. -->
<item name="snackbarTextViewStyle">@style/Custom.Snackbar.TextView</item>
....
</style>
然后为按钮,您可以使用android:textAppearance
属性定义自定义样式
<style name="Custom.TextButton.Snackbar" parent="@style/Widget.MaterialComponents.Button.TextButton.Snackbar">
<item name="android:textAppearance">@style/snackbar_button_textappearance</item>
</style>
仅是一个例子:
<style name="snackbar_button_textappearance" parent="@style/TextAppearance.MaterialComponents.Button">
<item name="android:textStyle">italic</item>
</style>
对于文本,您可以执行以下操作:
<style name="Custom.Snackbar.TextView" parent="@style/Widget.MaterialComponents.Snackbar.TextView">
<item name="android:textAppearance">......</item>
</style>
请note:
snackbarButtonStyle
属性需要版本1.1.0snackbarTextViewStyle
属性需要版本1.2.0。