Skip to content Skip to sidebar Skip to footer

How To Keep Round Corners For Button In Android When There Are Two-lines Words

I tried to make a button with round corners using the codes below: first_page_button.xml:

Solution 1:

You need to made some changes to Button properties and correct them as below.

Like

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:background="@color/white"
    android:padding="20dp"
    android:orientation="horizontal">

    <Button
        android:id="@+id/login_page_send_code"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="20dp"
        android:alpha="1"
        android:background="@drawable/first_page_button"
        android:minWidth="120dp"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:text="SE CONNECTOR"
        android:textColor="#EAEAEA"
        android:textSize="12sp"
        tools:ignore="ButtonStyle" />

    <Button
        android:id="@+id/login_page_login"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginStart="10dp"
        android:alpha="1"
        android:background="@drawable/first_page_button"
        android:minWidth="100dp"
        android:paddingBottom="12dp"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:paddingTop="12dp"
        android:text="Envoyer Le Code De Verification"
        android:textColor="#EAEAEA"
        android:textSize="15sp"
        tools:ignore="ButtonStyle" />
</LinearLayout>

first_page_button.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#199900" />

    <stroke
        android:width="1dp"
        android:color="@color/white" />

    <padding
        android:bottom="1dp"
        android:left="1dp"
        android:right="1dp"
        android:top="1dp" />

    <corners
        android:bottomLeftRadius="10dip"
        android:bottomRightRadius="10dip"
        android:topLeftRadius="10dip"
        android:topRightRadius="10dip" />
</shape>

Output

enter image description here


Solution 2:

Try this for your Shapes

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="@color/colorDarkWhite" />
    <corners android:bottomRightRadius="5dp"
        android:bottomLeftRadius="5dp"
        android:topRightRadius="5dp"
        android:topLeftRadius="5dp"/>
</shape>

Just adjust the corners the way you like it!


Solution 3:

check round corner button here

Try this Shapes drawable.

<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android"
  android:shape="rectangle">

<solid android:color="#3F51B5" />

<corners
    android:bottomLeftRadius="24dp"
    android:bottomRightRadius="24dp"
    android:topLeftRadius="24dp"
    android:topRightRadius="24dp" />
</shape>

Solution 4:

enter image description here

round_corner.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <corners android:radius="50dp" />

    <gradient
        android:angle="45"
        android:endColor="#00A46F"
        android:startColor="#00A46F" />

</shape>

Button

 <Button
        android:id="@+id/btn_login"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/et_login_password"
        android:layout_marginTop="25dp"
        android:background="@drawable/round_corner"
        android:padding="0dp"
        android:text="HELLO THIS IS A TEST APPLICATION "
        android:textAllCaps="false"
        android:textColor="@color/white"
        android:textSize="18sp" />

As per your XML file:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:layout_gravity="center"
        android:orientation="horizontal"
        android:weightSum="1">

        <Button
            android:id="@+id/login_page_send_code"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginRight="10dp"
            android:layout_weight=".5"
            android:paddingLeft="10dp"
            android:paddingRight="10dp"
            android:paddingTop="10dp"
            android:paddingBottom="10dp"
            android:background="@drawable/round_corner_green"
            android:singleLine="false"
            android:text="THIS IS YOUR FIRST BUTTON"
            android:textColor="#EAEAEA"
            android:textSize="13dp" />

        <Button
            android:id="@+id/login_page_login"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_weight=".5"
            android:paddingLeft="10dp"
            android:paddingRight="10dp"
            android:paddingTop="10dp"
            android:paddingBottom="10dp"
            android:background="@drawable/round_corner_green"
            android:text="THIS IS YOUR SECOND BUTTON"
            android:textColor="#EAEAEA"
            android:textSize="13dp" />
    </LinearLayout>
</RelativeLayout>

enter image description here

Set a android:radius as per your requirement of round corner button.

Hope this helps you.


Post a Comment for "How To Keep Round Corners For Button In Android When There Are Two-lines Words"