MaterialButton 样式 shapeAppearance 不工作
MaterialButton style shapeAppearance not working
我正在努力为项目中的按钮设置正确的样式。我不知道为什么 shapeAppearance
不工作。即使我只使用 cornerSize
它也不起作用。
我有一个按钮的基本样式:
<style name="SnButton" parent="Widget.MaterialComponents.Button.UnelevatedButton">
<item name="shapeAppearance">@style/MyShapeAppearance</item>
<item name="backgroundTint">@null</item>
</style>
这是我的按钮形状外观:
<style name="MyShapeAppearance" parent="ShapeAppearance.MaterialComponents.SmallComponent">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">2dp</item>
</style>
这是我的基本主题:Theme.MaterialComponents.Light.NoActionBar.Bridge
我应该怎么做才能强制 shapeAppearance
在我的案例中工作?或者至少 cornerSize
?
我弄明白为什么样式不起作用了!
问题出在我设置按钮颜色的方式上。我用了android:background
,但是必须用backgroundTint
。
我正在努力为项目中的按钮设置正确的样式。我不知道为什么 shapeAppearance
不工作。即使我只使用 cornerSize
它也不起作用。
我有一个按钮的基本样式:
<style name="SnButton" parent="Widget.MaterialComponents.Button.UnelevatedButton">
<item name="shapeAppearance">@style/MyShapeAppearance</item>
<item name="backgroundTint">@null</item>
</style>
这是我的按钮形状外观:
<style name="MyShapeAppearance" parent="ShapeAppearance.MaterialComponents.SmallComponent">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">2dp</item>
</style>
这是我的基本主题:Theme.MaterialComponents.Light.NoActionBar.Bridge
我应该怎么做才能强制 shapeAppearance
在我的案例中工作?或者至少 cornerSize
?
我弄明白为什么样式不起作用了!
问题出在我设置按钮颜色的方式上。我用了android:background
,但是必须用backgroundTint
。