Running PathDashPathEffect example - Hallo sahabat Teknologi Terbaru, Pada Artikel yang anda baca kali ini dengan judul Running PathDashPathEffect example, kami telah mempersiapkan artikel ini dengan baik untuk anda baca dan ambil informasi didalamnya. mudah-mudahan isi postingan yang kami tulis ini dapat anda pahami. baiklah, selamat membaca.
Judul : Running PathDashPathEffect example
link : Running PathDashPathEffect example
Running PathDashPathEffect example
This example implement running PathDashPathEffect, by varying phase parameter.Modify MyView.java from the post.
package com.example.androidview;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Path.Direction;
import android.graphics.PathDashPathEffect;
import android.util.AttributeSet;
import android.view.View;
public class MyView extends View {
Paint paint;
Path path;
Path pathShape;
float phase;
float advance;
PathDashPathEffect.Style style;
public MyView(Context context) {
super(context);
init();
}
public MyView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public MyView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
private void init() {
paint = new Paint();
paint.setColor(Color.RED);
paint.setStrokeWidth(20);
paint.setStyle(Paint.Style.STROKE);
path = new Path();
pathShape = new Path();
pathShape.addCircle(10, 10, 10, Direction.CCW);
phase = 0;
advance = 30.0f;
style = PathDashPathEffect.Style.ROTATE;
}
@SuppressLint("DrawAllocation")
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawColor(Color.GRAY);
path.reset();
path.moveTo(50, 50);
path.lineTo(50, getHeight()-50);
path.lineTo(getWidth()-50, getHeight()-50);
path.lineTo(getWidth()-50, 50);
path.close();
phase++;
PathDashPathEffect pathDashPathEffect =
new PathDashPathEffect(pathShape, advance, phase, style);
paint.setPathEffect(pathDashPathEffect);
canvas.drawPath(path, paint);
invalidate();
}
}
- Effect of advance, phase, style in PathDashPathEffect
- More examples of drawing path on custom View
Demikianlah Artikel Running PathDashPathEffect example
Sekianlah artikel Running PathDashPathEffect example kali ini, mudah-mudahan bisa memberi manfaat untuk anda semua. baiklah, sampai jumpa di postingan artikel lainnya.
0 Response to "Running PathDashPathEffect example"
Post a Comment