I have created a drawable button_oval.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true"
android:shape="rectangle">
<corners android:radius="120dp" />
<solid android:color="#eceef5" />
<stroke
android:width="3dp"
android:color="#29395e" />
<size
android:width="300dp"
android:height="120dp" />
</shape>
and then i use it on my layout like this:
// I want to add a icon inside this button
<Button
android:id="@+id/goToPersonalPage"
android:layout_width="110dp"
android:layout_height="50dp"
android:layout_marginLeft="30dp"
android:background="@drawable/button_oval"
android:text="@string/memberButton"
android:textColor="#29395e"
android:textSize="18dp" />
I want to add an icon inside the Button
, is it any possible to complete it by changing my button_oval.xml
?
The final output should look Just like the image below :
Any help would be greatly appreciated.
You have to add these lines in your Button element-
android:drawableLeft="@mipmap/ic_launcher_round" // to set an icon
android:drawablePadding="10dp" // to set the padding of icon from text
android:paddingLeft="20dp" // to set the padding of the icon and text
adjust the values according to your need.
It will look like-