D
D
David King2020-11-07 18:05:28
Android
David King, 2020-11-07 18:05:28

Why doesn't the button color change in Android Studio?

I'm trying to change the color of the button, it doesn't work. Here is the code

<Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/black"
            android:text="GO"
            android:layout_margin="2dp"/>

Here is a screenshot5fa6b7ab82481527746373.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Edward, 2020-11-07
@javaScriptIsPooP

a) try to do a rebuild project (studio preview can be buggy)
b) see what happens if you run it on a real or virtual device
c) make sure it @color/black's really black

S
Sergey Taramaly, 2021-05-06
@VivienAlive

60940f09c94a3694062535.jpeg
need another field to "color"

F
free2free, 2020-12-17
@free2free

Try changing the type of Baton. It works for me like this:

<androidx.appcompat.widget.AppCompatButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="test"
        android:background="@color/black"/>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question