I was creating a shape to use as a button background. I'm making a strip of buttons, and the one on the left edge is going to have rounded corners on the left, and the last one on the right will have rounded corners on the right. This is pretty simple, and the api docs show you just how to do it. However, when I used android:topLeftRadius
and android:bottomLeftRadius
, the result in the UI was as if I put bottomRightRadius. The same behavior was true of the other side. It appears that whoever implemented this swapped bottomRight and bottomLeft. I'll post a snippet of the code below.
Is there some logical reason for this that I might be missing? Or, if this was a mistake on the part of the Android engineers, will it stay backward compatible once they fix it? I imagine they'd have to make all new attributes to keep the old ones valid (leftTop instead of topLeft maybe?).
<?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>
Looks like a bug, see this issue and this question.
I can't seem to find it, but I recall reading somewhere that there was a bug that required you to first override the full radius, then set back the ones that you don't want to have a radius; for example:
<corners
android:radius="8dp"
android:topRightRadius="0dp"
android:bottomLeftRadius="0dp"
/>
I don't guarantee success, but you may give that a try.
EDIT: Ah, Donut seems to have the right answer.
<corners android:topLeftRadius="0.1dp"
android:topRightRadius="6dp"
android:bottomRightRadius="0.1dp"
android:bottomLeftRadius="6px" />
This will work for toleft and top right. adjust it with your requirement
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With