This is my very first question on StackOverflow, I expect great help from the community :) I've looked around for this problem's solution for hours but I'm kinda puzzled..
I'm trying to create a custom outlined rounded button for my android app but when I'm applying it through the android:background attribute in XML file, It doesn't quite work. The default background color (purple) is not removed. The stroke is not applied too. However, corners are rounded.
Some say android:background is not working on MaterialButtons. Some say create a style in themes.xml file and reapply it thru android:backgroundTint attribute (It doesn't work either). Some say try to change it programmatically(not working too!).
Please provide an efficient solution.
Here's my code and what I'm achieving with it.
activity_main
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:background="@drawable/round_button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
round_button
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="@color/black" />
<stroke
android:width="3dp"
android:color="@color/teal_200" />
<corners android:radius="25dp" />
</shape>
This is what I want to achieve.
I'm really looking forward to your answers! Thanks.