1

我有dotted_line_horizo​​ntal.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line" >
    <stroke
        android:dashGap="10px"
        android:dashWidth="10px"
        android:color="#5c5c5c" />

</shape>

我用这个作为背景:

   <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@drawable/dotted_line_horizontal" />

当我设置 android:targetSdkVersion="8" 一切都很好,我可以看到虚线。当我更改为 android:targetSdkVersion="17" 我的虚线变成了一条线。为什么?

4

1 回答 1

0

添加<solid>标签,如本答案中所指定。

<solid android:color="#ffffff" />

这将确保破折号部分与空白部分的颜色不同。

于 2014-02-15T23:38:39.943 回答