Monday, November 4, 2019

How to create a rounded corners Button in Android

create a rounded corners Button in Android

Step . create a layout : activity_main.xml

<Button
 android:id ="@+id/push_button"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="Rounded Corners Button"
 android:background="@drawable/button_bg_rounded_corners"
 android:padding="15dp"
 />
Step 2:  create a layout in drawable : res/drawable/button_bg_rounded_corners.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape android:shape="rectangle">
        <solid android:color="#DEB887"/>
        <stroke android:color="#8A2BE2" android:width="2dp" />
        <!--corners allow us to make the rounded corners button-->
        <corners android:radius="15dp" />
    </shape>
</item>
</selector>
Result How to create a rounded corners Button in Android below:
How to create a rounded corners Button in Android

1 comment:

  1. It turns out that even the hottest port has a few places where you can get off the beaten path. Here are some recommendations that will make you feel like you're in the know escanteios

    ReplyDelete