Comic error in Android xml form declaration

I created a form to use as the button background. I’m making a strip of buttons, and on the left edge there will be rounded corners on the left, and rounded corners on the right. It is quite simple, and api docs show you how to do it. However, when I used android:topLeftRadiusand android:bottomLeftRadius, the result in the user interface was as if I placed bottomRightRadius. The same behavior was true for the other side. It seems whoever implemented this has replaced bottomRight and bottomLeft. I will post the code snippet below.

Is there any logical reason for this that I can skip? Or, if it was a mistake on the part of Android engineers, will it remain backward compatible after fixing them? I assume that they would have to use all the new attributes so that the old ones are valid (e.g. leftTop instead of topLeft?).

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" >
        <shape>
            <solid android:color="#99000000" />
            <padding
                android:top="8dp"
                android:left="8dp"
                android:right="8dp"
                android:bottom="8dp" />
            <corners
                android:topLeftRadius="8dp"
                android:bottomRightRadius="8dp" />
        </shape>
    </item>
+5
source share
3 answers

Looks like a bug, see this question and this question .

+7
source

I can’t find it, but I remember reading somewhere that there is an error that required you to first redefine the full radius, and then return those that you do not want to have a radius; eg:

<corners
    android:radius="8dp"
    android:topRightRadius="0dp"
    android:bottomLeftRadius="0dp"
    />

, .

: , , , .

+2
<corners android:topLeftRadius="0.1dp" 
android:topRightRadius="6dp" 
android:bottomRightRadius="0.1dp" 
android:bottomLeftRadius="6px" />

This will work left and top right. adjust it with your requirement

+1
source

All Articles