Home > Blockchain >  shape does not fully works
shape does not fully works

Time:12-28

i have a shape

<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#D33535"/>
    <stroke android:width="3dp" android:color="#D33535" />
    <corners android:radius="20dp"/>
    <padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />
</shape>

which as i understand have to change buttons color to red. here is my button

<Button
    android:id="@ id/addExpenseButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="21dp"
    android:layout_marginBottom="10dp"
    android:background="@drawable/red_bg"
    android:text="@string/addExpenseButton"
    app:layout_constraintBottom_toTopOf="@ id/addIncomeButton"
    app:layout_constraintEnd_toEndOf="parent" />

but button have primary color. here is my colors

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="purple_200">#FFBB86FC</color>
    <color name="purple_500">#FF6200EE</color>
    <color name="purple_700">#FF3700B3</color>
    <color name="teal_200">#FF03DAC5</color>
    <color name="teal_700">#FF018786</color>
    <color name="black">#FF000000</color>
    <color name="white">#FFFFFFFF</color>
    <color name="primary">#4CAF50</color>
    <color name="red">#D33535</color>
    <color name="secondary">#009688</color>
</resources>

CodePudding user response:

Hello sir i think have the best solution for your query:

You can just use the AppCompatButton for your solution

Your xml will be

<androidx.appcompat.widget.AppCompatButton
    android:id="@ id/addExpenseButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="108dp"
    android:background="@drawable/red_bg"
    android:text="addExpenseButton"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintBottom_toTopOf="@ id/addIncomeButton"
    tools:layout_editor_absoluteY="211dp" />

CodePudding user response:

Your shape is missing the shape attribute

android:shape="rectangle"

Add it to the shape tag

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
  • Related