bug in android 2.1 xml drawables?
Looking at t开发者_如何学Che following image, the button on the left is android 2.1, the one on the right is 2.2:
As you can see the corners on the left image are not being applied correctly, but they look perfect in 2.2. The xml I'm using is here:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:right="0dip" android:left="0dip" android:bottom="0dip"
android:top="0dip">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:bottomRightRadius="3dip"
android:bottomLeftRadius="3dip" android:topLeftRadius="3dip"
android:topRightRadius="3dip" />
<stroke android:width="1dip" android:color="#70532B" />
<padding android:left="1dip" android:top="1dip"
android:right="1dip" android:bottom="1dip" />
</shape>
</item>
<item android:right="0dip" android:left="0dip" android:bottom="0dip"
android:top="9dip">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="#ECAF08" android:endColor="#F6E34B"
android:angle="270" />
<corners android:bottomRightRadius="3dip"
android:bottomLeftRadius="3dip" android:topLeftRadius="0dip"
android:topRightRadius="0dip" />
</shape>
</item>
<item android:right="0dip" android:left="0dip" android:bottom="11dip"
android:top="0dip">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="#FCEF94" android:endColor="#FFBA00"
android:angle="270" />
<corners android:bottomRightRadius="0dip"
android:bottomLeftRadius="0dip" android:topLeftRadius="3dip"
android:topRightRadius="3dip" />
</shape>
</item>
am i doing something wrong, or is this a bug in android 2.1???
Clever way to make a gradient button.
I wonder if this is related to the <corners>
xml being buggy in Android 2.1 and below. bottomLeftRadius actually corresponds to bottomRightRadius, and vice versa. They may have fixed it in 2.2, thus it looks correct in 2.2, but you're overlapping in unexpected ways in 2.1 and lower. If that's the case, you can use version-targeted folders to use a different drawable for each version (aka, /drawable-v7/
and /drawable-v8/
).
精彩评论