简体   繁体   中英

button background color is always purple in android studio

I am coding in android studio for some months and everything worked great. In the last 2 weeks I updated android studio and since then, every time I put a button its color is defined as purple no matter what I am doing, even if I change its background. I tried to change it from the xml and also from the java file but without success. If someone knows how to change it, it would be very helpful. Thanks for answers.

the color of the button

Instead of button use <androidx.appcompat.widget.AppCompatButton>

Setting the app:backgroundTint to the color or transparent as well fixed this for me.

Change the theme.xml

style name="Theme.PROJECTNAME" parent="Theme.AppCompat.Light.NoActionBar">

Then the button without background will become grey and can be edited by color and drawable

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM