hpi*_*que 15 animation android border
如何在Android中创建任意形状的动画虚线或虚线边框?在XML(首选)或以编程方式.
有关示例,请参见下图.

ant*_*nyt 19
您是否看过PathEffects API演示? http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/PathEffects.html
它可以精确地生成动画线,您只需调整视图边缘的路径即可创建边框.例如:
根据视图参数/任意形状定义路径:
Path path = new Path();
path.addRect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom(), Path.Direction.CW);
Run Code Online (Sandbox Code Playgroud)
然后使用以下命令创建一个虚线PathEffect:
PathEffect pe = new DashPathEffect(new float[] {10, 5, 5, 5}, phase);
Run Code Online (Sandbox Code Playgroud)
然后设置它与Paint对象关联并绘制:
mPaint.setPathEffect(pe);
canvas.drawPath(path, mPaint);
Run Code Online (Sandbox Code Playgroud)
编辑:动画效果来自不断改变阶段和重绘.在API演示中,它调用onDraw()方法中的invalidate()(触发onDraw()...)
| 归档时间: |
|
| 查看次数: |
4905 次 |
| 最近记录: |