Fil*_*oli 10 android material-components material-components-android
如何使用新的材质组件从按钮中删除等宽字体?
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_register"
style="@style/Widget.MaterialComponents.Button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
app:fontFamily="@font/lato"
app:backgroundTint="@color/white"
android:textColor="?colorPrimary"
android:text="Open Register Screen" />
Run Code Online (Sandbox Code Playgroud)
此图显示了我要消除的差异:

要全局更新所有Button的字母间距,应使用以下主题:https://material.io/develop/android/theming/typography/
您可以在主题中重新定义?attr / textAppearanceButton,以指向具有所需letterSpacing的其他文本外观。
像这样在主题中定义attr:
<style name="Theme.MyApp" parent="Theme.MaterialComponents.Light">
<item name="textAppearanceButton">@style/TextAppearance.MyApp.Button</item>
</style>
Run Code Online (Sandbox Code Playgroud)
并创建一个新的TextAppearance样式:
<style name="TextAppearance.MyApp.Button" parent="TextAppearance.MaterialComponents.Button">
<item name="android:letterSpacing">0</item>
</style>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1026 次 |
| 最近记录: |