0

i want to add button color but it didnt show up

here is the drawable rounded_button.xml

<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#47D476"/>
    <corners android:radius="15dp"/>
</shape>

and this the layout

<Button
            android:id="@+id/buttonOKE"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:background="@drawable/rounded_button"
            android:text="SUBMIT"
            />

how to set the colors it didnt change to green

color from the rounded_button.xml

the result

thank you.

Learner
  • 27
  • 6

3 Answers3

2

You should set @null at backgroundTint .

 app:backgroundTint="@null"

Final Button xml code:

<Button
            android:id="@+id/buttonOKE"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:text="SUBMIT"
            app:backgroundTint="@null"
            android:background="@drawable/rounded_button"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            />
TANIMUL ISLAM
  • 320
  • 2
  • 5
0

You can try adding the following code to the button.

app:backgroundTint="@null"
花未开
  • 159
  • 1
  • 6
0

You can use textview instead of button like this

       <TextView
             android:id="@+id/tvDiscount"
             style="@style/txt_white_small"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_gravity="start
             android:background="@drawable/discount_horizontal"
             android:gravity="center"
             android:paddingLeft="@dimen/_5sdp"
             android:paddingRight="@dimen/_5sdp"
             android:text="" />


You can apply color and shape both things at once