Ok so my buttons are not showing gradient as they should be (the gradient is not showing, its just a normal color background), idk why this is happening, everything looks like how it should be to me, can someone please take a look :
activity_main.xml
...
<Button
android:id="@+id/button1"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:background="@drawable/button"
app:icon="@drawable/ic_baseline_room_service_24"
android:fontFamily="monospace"
android:padding="15dp"
android:paddingEnd="40dp"
android:text="BROWSE BY INGREDIENTS"
android:textColor="#FFFFFF"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/guideline2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.084"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/viewPager"
app:layout_constraintVertical_bias="0.396" />
...
Here's a photo of the button as seen in the layout : button (gradient not working)
button.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<gradient
android:startColor="#1746D3"
android:endColor="#6D34CF"/>
<corners
android:bottomRightRadius="900dp"
android:radius="90dp"/>
</shape>
</item>
</selector>
Here's a photo of the gradient background : gradient
However, the android:background="..."
does show the mini preview at the side : button_preview
Any help is appriciated!
Replace in Button
with androidx.appcompat.widget.AppCompatButton
in activity_main.xml
It seems that using Button it is not possible to have the complete personalization of the widget.
Button
widget handles its own background and you can only use tinting to change its color. This is an open issue and hasn't been fixed yet.