【发布时间】:2015-07-07 15:36:47
【问题描述】:
请注意,我确实在 SO 上引用了创建短划线问题,并通过 Google 进行了各种搜索......无论如何,问题就是这样。我无法通过 xml 绘制虚线(可以使用 DashPathEffect 但不想继续这样做)。这是我使用的 dash drawable (dash_line.xml):
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:color="@color/whiteColor"
android:dashWidth="10dp"
android:width="10dp"
android:dashGap="4dp"/>
</shape>
现在,在 xml 中为 imageview 实现:
<ImageView
android:id="@+id/dash_test"
android:layout_width="200dp"
android:layout_height="10dp"
android:background="@drawable/dash_line"/>
我正在使用 Android API 18。我什至通过设置层类型(在 xml 和以编程方式尝试)在清单甚至视图本身中禁用硬件加速。我通过查看 dashView.isHardwareAccelerated() 进行了验证,它是错误的。关于我缺少什么的任何想法?
编辑: 顺便说一句,我可以画实线,所以我知道这不是分层问题。
编辑: 一种解决方法是使用 PathDashEffect。尽管那时您会遇到无法在图像上绘图的问题(我需要这样做)。所以...仍然想要一个 xml 解决方案。
【问题讨论】:
标签: java android xml user-interface