Selutario :
I'm trying to create an android button whose text can be changed (to be able to internationalize the app easily), but at the same time have a background, and using rounded corners if possible.
So far, if I use a background image I can not get the corners to be round and vice versa.
The last thing I tried is to create these xml file
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<stroke android:width="2dp" android:color="#FF404040" />
<corners android:radius="6dp" />
<gradient android:startColor="#FF6800" android:centerColor="#FF8000" android:endColor="#FF9700" android:angle="90" />
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<stroke android:width="2dp" android:color="#FF404040" />
<corners android:radius="6dp" />
<gradient android:startColor="#FF6800" android:centerColor="#FF8000" android:endColor="#FF9700" android:angle="90" />
</shape>
and this button, but I can not put a background image:
<Button
android:id="@+id/button"
android:layout_width="235dp"
android:layout_height="wrap_content"
android:background="@drawable/background_selector"
android:text="Button"
tools:layout_editor_absoluteX="101dp"
tools:layout_editor_absoluteY="277dp" />
What I'm trying to achieve is a result similar to the Morning Ritual button in this app, for example, if that is a button, which I do not know either.
Deˣ :
You can use CardView
or If you want to create Button
, try this xml drawable:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle" android:padding="5dp">
<corners
android:bottomRightRadius="4dp"
android:bottomLeftRadius="4dp"
android:topLeftRadius="4dp"
android:topRightRadius="4dp"/>
</shape>
</item>
<item android:drawable="@drawable/yourImage" />
</layer-list>