Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Max value for rectangle's rounded corners in Android

I am trying to get a shape as shown in figure, a rectangle with corners completely round: enter image description here

But it seems I can't get corners "rounder" than in this figure:

enter image description here

Why is that? there is a max value for <corners android:radius="integer" />? Of course I could do that with a png, but I suppose using a shape is more efficient, so I would prefer that.

My code:

<Button
    android:id="@+id/button_guest"
    android:layout_width="315dp"
    android:layout_height="80dp"
    android:background="@drawable/rounded_rectangle"
    android:contentDescription="@string/text_button_guest"
    android:onClick="startGuestMode"
    android:text="@string/text_button_normal"
    android:textAllCaps="false"
    android:textColor="#ff000000"
    android:textSize="50sp"
    android:layout_marginLeft="125dp"
    android:layout_marginStart="125dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

rounded_rectangle.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#ffffff" />
    <corners
        android:radius="40dp" />
</shape>
like image 474
ocramot Avatar asked Dec 19 '22 04:12

ocramot


1 Answers

Ok, I love when I scratch my head for hours, then I end up asking a question here, and then I find an answer by myself in less than 10 minutes :D

The solution is in my code below. You would think it should have the same behaviour, but apparently it has not. Probably another bug about rounded corners.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#ffffff" />
    <corners
        android:bottomLeftRadius="40dp"
        android:bottomRightRadius="40dp"
        android:topRightRadius="40dp"
        android:topLeftRadius="40dp"
        />
</shape>
like image 118
ocramot Avatar answered Feb 01 '23 12:02

ocramot