Why am I not able to get my button to be rounded?

43 views Asked by At

I have created an xml file called rounded_button.xml for a custom rounded button design that I plan on using in my login screen.

This is the code I have in my xml file

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="@color/colorPrimaryDark"/>
    <corners
        android:topRightRadius="100px"
        android:topLeftRadius="100px"
        android:bottomRightRadius="100px"
        android:bottomLeftRadius="100px"
        />
</shape>

I have tried to implement it in my login screen like this

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
    tools:context=".LoginActivity">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Round"
        android:background="@drawable/round_button"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

However, the button is still rectangular, and even if I increase the corner sizes, it won't round the edges

  1. What have I done wrong?
  2. Is there a better way to structure my xml file to round the button?
0

There are 0 answers