1

看下图,左边的按钮是android 2.1,右边的是2.2:

替代文字

如您所见,左侧图像上的角没有正确应用,但它们在 2.2 中看起来很完美。我正在使用的 xml 在这里:

<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>

我做错了什么,或者这是android 2.1中的一个错误???

4

1 回答 1

2

制作渐变按钮的巧妙方法。

我想知道这是否与<corners>Android 2.1 及更低版本中的 xml 错误有关。bottomLeftRadius 实际上对应于 bottomRightRadius,反之亦然。他们可能已经在 2.2 中修复了它,因此它在 2.2 中看起来是正确的,但是在 2.1 及更低版本中您以意想不到的方式重叠。如果是这种情况,您可以使用以版本为目标的文件夹为每个版本(又名/drawable-v7//drawable-v8/)使用不同的可绘制对象。

于 2010-07-23T14:06:25.827 回答