主题设置为Theme.MaterialComponents时, 会忽略button的background.
解决
- 在res/values/themes.xml 中
parent="Theme.MaterialComponents.DayNight.DarkActionBar" 修改为
parent="Theme.MaterialComponents.DayNight.NoActionBar.Bridge"
这样就可以解决background的问题了, 但是按钮会失去ripple效果
- 使用 <android.widget.Button> 替代 <Button>