返回信息流怎么在Canvas上绘制带阴影的直线
这是一条镜像帖。来源:北邮人论坛 / mobile-terminal-at / #27175同步于 2015/11/23
该镜像源已超过 30 天没有更新,可能在源站已被删除。
MobileTerminalAT机器人发帖
Canvas画图。
hunanmange
2015/11/23镜像同步7 回复
订阅后,新回复会通过你的通知中心匿名送达。
7 条回复
Paint linePaint = new Paint();
linePaint.setShadowLayer(10, 5, 5, Color.BLACK);
PathEffect effects = new DashPathEffect(new float[]{20,20,20,20},1);
linePaint.setPathEffect(effects);
linePath = new Path();
linePath.moveTo(pointA.x, pointA.y);
linePath.lineTo(pointB.x, pointB.y);
canvas.drawPath(linePath, linePaint);
linePath.close();
[ema11][ema11]
【 在 qiaowh1991 的大作中提到: 】
: Paint linePaint = new Paint();
: linePaint.setShadowLayer(10, 5, 5, Color.BLACK);
: PathEffect effects = new DashPathEffect(new float[]{20,20,20,20},1);
: ...................
大神
【 在 fuxuemingzhu 的大作中提到: 】
: 借楼问怎么画虚线
虚线:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
<!--实线宽度为dashWith,空隙的宽度为dashGap-->
<stroke
android:dashGap="2dp"
android:dashWidth="3dp"
android:color="@color/black" />
<!-- 线的高度 -->
<size android:height="1dp" />
</shape>
还要设这个
android:layerType="software"
谢啦[ema0]我试试
【 在 ytinrete (ytinrete) 的大作中提到: 】
: 虚线:
: <?xml version="1.0" encoding="utf-8"?>
: ...................
【 在 fuxuemingzhu 的大作中提到: 】
: 谢啦我试试
发现了一个bug
这个虚线在api 20 之后不显示
需要在stroke里面加入width才行。。。
改成下下面的就好:
<stroke
android:width="1dp"
android:dashGap="2dp"
android:dashWidth="3dp"
...
哎呀呀呀,线上的bug终于还是被发现了orz