请帮帮我。
同时将主题从亮模式更改为暗模式。如何将按钮的主题从filledbutton更改为outlinedbutton?
我在play商店看到了一个应用程序。在这里,我注意到按钮主题正在发生变化:
这是轻量级模式:

这是暗模式:

我想像这样改变按钮的主题。有谁能告诉我怎么做吗?
任何帮助都将不胜感激
谢谢。
发布于 2021-06-03 13:20:28
使用“androidx.appcompat.widget.AppCompatButton”代替“Button”,它会随着UI主题的变化而自动改变。Please check Image here for better Understanding
发布于 2021-06-15 16:42:13
在主题中使用materialButtonStyle属性:
<style name="AppTheme" parent="Theme.MaterialComponents.*">
...
<item name="materialButtonStyle">@style/CustomButton</item>
</style>然后在一个轻巧的主题中使用Widget.MaterialComponents.Button作为父主题:
<style name="CustomButton" parent="@style/Widget.MaterialComponents.Button">
...
</style>在values-night目录中,使用Widget.MaterialComponents.Button.OutlinedButton作为父目录:
<style name="CustomButton" parent="Widget.MaterialComponents.Button.OutlinedButton">
...
</style>https://stackoverflow.com/questions/67704186
复制相似问题