编程知识 cdmana.com

Android use android:background Modify the problem of user defined button failure

Cause analysis : default <Button> The label is actually MaterialButton , MaterialButton  Will automatically ignore <background>, By default

Theme.MaterialComponents.DayNight.DarkActionBar  Style in 

Solution :

1 If you just change the color , You can use < android:backgroundTint > Instead of

2 If you want to use custom xml style , Can be

Theme.MaterialComponents.DayNight.DarkActionBar   It is amended as follows  
Theme.MaterialComponents.DayNight.NoActionBar.Bridge

But this approach can lead to a global style change

3 use <android.widget.Button> Instead of <Button>

版权声明
本文为[Sad Warrior]所创,转载请带上原文链接,感谢
https://cdmana.com/2020/12/20201224161353383b.html

Scroll to Top