I have issues when design button in android. How can I make button like same the picture below
Asked
Active
Viewed 314 times
0
-
Possible duplicate of [How to make the corners of a button round](http://stackoverflow.com/questions/6054562/how-to-make-the-corners-of-a-button-round) – Ye Lin Aung Sep 10 '13 at 07:11
-
Thank you. I try set radius but it's not like same under ! ! :( – Lê Quốc Tiến Sep 10 '13 at 07:13
2 Answers
1
Make one file named yourfilename.xml in your drawable folder and put below code in it.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners
android:bottomLeftRadius="7dp"
android:bottomRightRadius="7dp"
android:topLeftRadius="7dp"
android:topRightRadius="7dp">
</corners>
<stroke android:color="#FFFFFF"
android:width="1dp"></stroke>
</shape>
In your main.xml file put below code.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FBBECB">
<Button
android:layout_width="55dp"
android:layout_height="wrap_content"
android:text="Button"
android:background="@drawable/yourfilename"
android:id="@+id/button"
android:layout_gravity="center"
android:layout_marginTop="73dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="54dp" />
</RelativeLayout>
that's it.

Jitesh Dalsaniya
- 1,917
- 3
- 20
- 36
1
you have to make custom file in your drawable folder..
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners
android:bottomLeftRadius="8dp"
android:bottomRightRadius="8dp"
android:topLeftRadius="8dp"
android:topRightRadius="8dp">
<stroke android:color="#FFFFFF"
android:width="1dp"></stroke>
</shape>
And then use it in your xml file file for button
Like:
android:background="@drawable/customfile" // get from drawable folder

Piyush
- 18,895
- 5
- 32
- 63