-->

Android的虚线绘制的潜在ICS的bug(Android dashed line drawabl

2019-07-29 16:18发布

以下是虚线,定义为XML一个ShapeDrawable:

<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line">

    <size
        android:height="2dp"
        android:width="700dp" />

    <stroke
        android:width="1dp"
        android:color="@android:color/black"
        android:dashWidth="1dp"
        android:dashGap="2dp" />

</shape>

这将画上几个姜饼手机一个不错的虚线。 在Galaxy的Nexus然而,破折号似乎被忽略,并且形状被绘制为连续的线。 更好奇,运行ICS模拟器将与破折号正确渲染它,它只是搞砸了物理设备。

我失去了一些东西明显? 还是这真的与Android 4.0中的错误? 该生产线在多个地方使用。 下面是一个例子ImageView的:

<ImageView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="@dimen/observation_observe_side_margin"
    android:layout_marginRight="@dimen/observation_observe_side_margin"
    android:layout_marginTop="16dp"
    android:contentDescription="@string/dotted_line_description"
    android:src="@drawable/dotted_line" />

Answer 1:

这一问题已被记录在这里http://code.google.com/p/android/issues/detail?id=29944关闭硬件加速将显示虚线。



Answer 2:

在记录问题http://code.google.com/p/android/issues/detail?id=29944具有应用以下到您的视图的评论:

view.setLayerType(View.LAYER_TYPE_SOFTWARE, null)

这为我工作。



文章来源: Android dashed line drawable potential ICS bug