Reputation: 27
I have issues when design button in android. How can I make button like same the picture below
Upvotes: 0
Views: 318
Reputation: 18933
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
Upvotes: 1
Reputation: 1917
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.
Upvotes: 1