简体   繁体   中英

How do i change the background on the buttons XML-AndroidStudio?

I am developing a small app in Android Studio, but I can't change the button color. I've tried everyting, changing only the background, the backgroundtint, to make a new drawable object, but I can't seem to find any answer, this is my button XML layout:

<Button
    android:id="@+id/calc"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="55dp"
    android:layout_marginTop="45dp"
    android:background="@drawable/round_green_shape"
    android:text="CALCULA">
</Button>

And this is the XML for my background:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    android:padding = "10dp">

<solid android:color="@color/buttonsGreen">
</solid>

<corners
    android:radius="15dp">
</corners>
</shape>

But this is how my bottons look: 在此处输入图像描述

And on the app they look the same: 在此处输入图像描述

I would appreciate any help,

Thank you

Done, i just had to delete the

android:background = ""

and just set the:

android:backgroundTint = ""

to green...

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