材料设计印刷和小吃店

问题描述 投票:1回答:1

https://material.io/develop/android/theming/typography/,我一直在通过修改textAppearanceX属性来自定义应用的样式。是否有人知道要自定义哪个属性来设置应用程序的小吃店的样式或该文件的记录位置?

谢谢。

android material-design android-theme android-snackbar material-components-android
1个回答
0
投票

使用材料组件库,您可以通过应用程序主题自定义文本和按钮所使用的textAppearance

只需使用snackbarButtonStylesnackbarTextViewStyle属性在应用程序中定义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>

enter image description here

note

  • snackbarButtonStyle属性需要版本1.1.0
  • snackbarTextViewStyle属性需要版本1.2.0
© www.soinside.com 2019 - 2024. All rights reserved.