btn_plus and btn_minus not displaying properly in kotlin

Viewed 28

I cannot get a plus or minus button to display properly. Any other button I've tried has had no problem so I'm unsure why the issue with those two. The button just displays a small solid circle on te button instead of a plus or minus.

<com.google.android.material.floatingactionbutton.FloatingActionButton

        android:id="@+id/newItem"
        android:layout_width="139dp"
        android:layout_height="125dp"
        android:layout_gravity="bottom|end"

        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:srcCompat="@android:drawable/btn_plus"
        />```
2 Answers

You can try use android:src="@drawable/btn_plus" instead of app:srcCompat="@android:drawable/btn_plus" and custom color/background color for it by useapp:backgroundTint="your_color" app:tint="your_color". Hope it help!

You can simply use ImageView with a drawable like this:

                    <ImageView
                    android:id="@+id/btn_minus"
                    android:layout_width="30dp"
                    android:layout_height="30dp"
                    android:src="@drawable/ic_decrement_circle"/>

And here's the drawable :

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="@color/primary">
<path
    android:fillColor="@android:color/white"
    android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM17,13L7,13v-2h10v2z"/>
Related