Jump To Right Section
Show
In this post, we want to discuss about a nice function to button shape using drawable in Android Studio. Before we get started, if you want to know about Listview binding in android, please go through the following article: How to bind simple Listview in Android.
How to Start
Now we create a drawable resource file as “button_shape” under drawables folder in Android Studio. You can set some different properties like stroke, corner, padding and color etc. For test the process quickly, you may copy the following code:
Create drawable resource file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="1dp"
android:color="@color/colorAccent"/>
<corners android:radius="7dp" />
<padding
android:left="1dp"
android:right="1dp"
android:top="1dp"
android:bottom="1dp"/>
<solid android:color="@color/colorPrimary"/>
</shape> |
1 2 3 |
android:background="@drawable/button_shape" |
Leave a Comment