2

自 HTC One 的 Sense 5.5 的 Android 4.3 更新以来,我的主屏幕小部件出现了一些奇怪的行为,但仅在此设备上。他们有一个像这样的 Background-Shape-Drawable:

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <stroke
        android:width="2dp"
        android:color="#CCFFFFFF" />

    <gradient
        android:angle="225"
        android:endColor="#99346b9f"
        android:startColor="#55346b9f" />

    <corners
        android:bottomLeftRadius="17dp"
        android:bottomRightRadius="17dp"
        android:topLeftRadius="17dp"
        android:topRightRadius="17dp" />

</shape>

有时背景显示正确,但通常背景变为白色而不是透明蓝色。我没有找到任何 Open-GL 错误日志或其他可以解释此错误的内容。所以我尝试使用背景可绘制对象。现在我想我已经找到了一个解决方案,我需要更多的测试来验证这一点,但我会传播这个,因为我没有找到任何其他帮助。我唯一改变的是将四个角属性结合到 android:radius 属性中。看一看:

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <stroke
        android:width="2dp"
        android:color="#CCFFFFFF" />

    <gradient
        android:angle="135"
        android:endColor="#884d8bc3"
        android:startColor="#881d3449" />

    <corners
        android:radius="17dp" />

</shape>

所以这似乎有帮助,但我不知道为什么会导致:

机器人:半径尺寸。所有角的半径,作为尺寸值或尺寸资源。这被以下属性覆盖每个角。

http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape

应该是等价的。但在 HTC One 上却不是这样。

4

0 回答 0