AndroidStudio无法改变Button背景颜色办理办法
利用版本:android studio-hedgehog(2023年的刺猬版)题目描述:由图观测到Button设置的是#cccccc(灰色),但按钮仍然为紫色https://img-blog.csdnimg.cn/direct/d937a08c1364459a944e782914393d48.png
题目原因:此版本默认利用的主题,覆盖了Button的背景色设置
办理办法:在工程里找到themes.xml文件打开(工程→项目→res→values→themes.xml)
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Base.Theme.MyApplication" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Customize your light theme here. -->
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
</style>
<style name="Theme.MyApplication" parent="Base.Theme.MyApplication" />
</resources> 把其中
<style name="Base.Theme.MyApplication" parent="Theme.Material3.DayNight.NoActionBar"> parent背面的值改为Theme.MaterialComponents.DayNight.NoActionBar.Bridge
<style name="Base.Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.NoActionBar.Bridge"> 留意,是替换文本,按照网络上很多办理办法说的直接在末端加.Bridge会报error:
Cannot resolve symbol 'Theme.Material3.DayNight.NoActionBar.Bridge'
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]