我创建了一组在 Android 4.4 上完美运行的形状:
然而,当我在2.3上测试它时:
底角调换了,凝结了(很可能是高度问题)。
因此,我决定创建一个类似 drawable-v14
的文件夹,并为不同版本分配不同的形状,但我需要知道哪些 Android 版本存在错误。我无法在所有版本上测试它!
编辑
7 号按钮的形状:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle">
<solid android:color="@color/rounded_stroke_color" />
<corners
android:topLeftRadius="0dp"
android:topRightRadius="0dp"
android:bottomLeftRadius="@dimen/rounded_radius_default"
android:bottomRightRadius="0dp" />
</shape>
</item>
<item
android:top="@dimen/rounded_stroke_normal_half"
android:bottom="@dimen/rounded_stroke_normal"
android:left="@dimen/rounded_stroke_normal"
android:right="@dimen/rounded_stroke_normal_half">
<shape android:shape="rectangle">
<solid android:color="@color/rounded_fill_color" />
<corners
android:topLeftRadius="0dp"
android:topRightRadius="0dp"
android:bottomLeftRadius="@dimen/rounded_radius_default"
android:bottomRightRadius="0dp" />
<padding
android:left="@dimen/rounded_padding_left"
android:right="@dimen/rounded_padding_right" />
</shape>
</item>
</layer-list>
顺便说一句,这些值存储在不同的资源文件中。
最佳答案
好的,让我们从您的代码开始。 首先,您不需要为此拥有图层列表。你可以这样做:
<shape android:shape="rectangle">
<solid android:color="@color/rounded_stroke_color" />
<stroke android:color="@color/comments_dark_color" android:width="@dimen/stroke_width"/>
<corners
android:topLeftRadius="0dp"
android:topRightRadius="0dp"
android:bottomLeftRadius="@dimen/rounded_radius_default"
android:bottomRightRadius="0dp" />
</shape>
关于角的问题,你是对的。这是已知错误https://code.google.com/p/android/issues/detail?id=9161 。此错误已在 android 3.1 中修复
正如 @DerGolem 所说,有黑客攻击:
Lucky us, there is a workaround: the workaround is to put the "correct" drawbles in the drawable-v12 folder, and the reversed ones in the drawable folder
关于Android 形状错误在哪个 Android 版本上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23647320/