本文整理汇总了Java中android.graphics.DashPathEffect类的典型用法代码示例。如果您正苦于以下问题:Java DashPathEffect类的具体用法?Java DashPathEffect怎么用?Java DashPathEffect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DashPathEffect类属于android.graphics包,在下文中一共展示了DashPathEffect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDraw
import android.graphics.DashPathEffect; //导入依赖的package包/类
@[email protected]("DrawAllocation")
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isInEditMode()) {//这段代码在运行时不会执行,只会在Studio编辑预览时运行,不用在意性能问题
int d = DensityUtil.dp2px(5);
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setColor(0x44ffffff);
paint.setStrokeWidth(DensityUtil.dp2px(1));
paint.setPathEffect(new DashPathEffect(new float[]{d, d, d, d}, 1));
canvas.drawRect(d, d, getWidth() - d, getBottom() - d, paint);
TextView textView = new TextView(getContext());
textView.setText(getClass().getSimpleName()+" 虚假区域\n运行时代表下拉Header的高度【" + DensityUtil.px2dp(getHeight()) + "dp】\n而不会显示任何东西");
textView.setTextColor(0x44ffffff);
textView.setGravity(Gravity.CENTER);
textView.measure(makeMeasureSpec(getWidth(), EXACTLY), makeMeasureSpec(getHeight(), EXACTLY));
textView.layout(0, 0, getWidth(), getHeight());
textView.draw(canvas);
}
}
示例2: onDraw
import android.graphics.DashPathEffect; //导入依赖的package包/类
@[email protected]("DrawAllocation")
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isInEditMode()) {//这段代码在运行时不会执行,只会在Studio编辑预览时运行,不用在意性能问题
int d = DensityUtil.dp2px(5);
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setColor(0x44ffffff);
paint.setStrokeWidth(DensityUtil.dp2px(1));
paint.setPathEffect(new DashPathEffect(new float[]{d, d, d, d}, 1));
canvas.drawRect(d, d, getWidth() - d, getBottom() - d, paint);
TextView textView = new TextView(getContext());
textView.setText(getClass().getSimpleName()+" 虚假区域\n运行时代表上拉Footer的高度【" + DensityUtil.px2dp(getHeight()) + "dp】\n而不会显示任何东西");
textView.setTextColor(0x44ffffff);
textView.setGravity(Gravity.CENTER);
textView.measure(makeMeasureSpec(getWidth(), EXACTLY), makeMeasureSpec(getHeight(), EXACTLY));
textView.layout(0, 0, getWidth(), getHeight());
textView.draw(canvas);
}
}
示例3: onDraw
import android.graphics.DashPathEffect; //导入依赖的package包/类
@Override
@SuppressLint("DrawAllocation")
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isInEditMode()) {//这段代码在运行时不会执行,只会在Studio编辑预览时运行,不用在意性能问题
int d = DensityUtil.dp2px(5);
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setColor(0x44ffffff);
paint.setStrokeWidth(DensityUtil.dp2px(1));
paint.setPathEffect(new DashPathEffect(new float[]{d, d, d, d}, 1));
canvas.drawRect(d, d, getWidth() - d, getBottom() - d, paint);
TextView textView = new TextView(getContext());
textView.setText(getClass().getSimpleName()+" 虚假区域\n运行时代表下拉Header的高度【" + DensityUtil.px2dp(getHeight()) + "dp】\n而不会显示任何东西");
textView.setTextColor(0x44ffffff);
textView.setGravity(Gravity.CENTER);
textView.measure(makeMeasureSpec(getWidth(), EXACTLY), makeMeasureSpec(getHeight(), EXACTLY));
textView.layout(0, 0, getWidth(), getHeight());
textView.draw(canvas);
}
}
示例4: onDraw
import android.graphics.DashPathEffect; //导入依赖的package包/类
@Override
@SuppressLint("DrawAllocation")
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isInEditMode()) {//这段代码在运行时不会执行,只会在Studio编辑预览时运行,不用在意性能问题
int d = DensityUtil.dp2px(5);
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setColor(0x44ffffff);
paint.setStrokeWidth(DensityUtil.dp2px(1));
paint.setPathEffect(new DashPathEffect(new float[]{d, d, d, d}, 1));
canvas.drawRect(d, d, getWidth() - d, getBottom() - d, paint);
TextView textView = new TextView(getContext());
textView.setText(getClass().getSimpleName()+" 虚假区域\n运行时代表上拉Footer的高度【" + DensityUtil.px2dp(getHeight()) + "dp】\n而不会显示任何东西");
textView.setTextColor(0x44ffffff);
textView.setGravity(Gravity.CENTER);
textView.measure(makeMeasureSpec(getWidth(), EXACTLY), makeMeasureSpec(getHeight(), EXACTLY));
textView.layout(0, 0, getWidth(), getHeight());
textView.draw(canvas);
}
}
示例5: DashedLine
import android.graphics.DashPathEffect; //导入依赖的package包/类
public DashedLine(Context context, AttributeSet attrs) {
super(context, attrs);
int dashGap, dashLength, dashThickness;
int color;
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.DashedLine, 0, 0);
try {
dashGap = a.getDimensionPixelSize(R.styleable.DashedLine_dashGap, 5);
dashLength = a.getDimensionPixelSize(R.styleable.DashedLine_dashLength, 5);
dashThickness = a.getDimensionPixelSize(R.styleable.DashedLine_dashThickness, 3);
color = a.getColor(R.styleable.DashedLine_color, 0xff000000);
orientation = a.getInt(R.styleable.DashedLine_orientation, ORIENTATION_HORIZONTAL);
} finally {
a.recycle();
}
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setColor(color);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(dashThickness);
mPaint.setPathEffect(new DashPathEffect(new float[]{dashLength, dashGap,}, 0));
}
示例6: setupStrokePaint
import android.graphics.DashPathEffect; //导入依赖的package包/类
/**
* Sets up paint according to the props set on a shadow view. Returns {@code true}
* if the stroke should be drawn, {@code false} if not.
*/
protected boolean setupStrokePaint(Paint paint, float opacity, @Nullable RectF box) {
paint.reset();
if (TextUtils.isEmpty(mStrokeColor)) {
return false;
}
paint.setFlags(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeCap(mStrokeLinecap);
paint.setStrokeJoin(mStrokeLinejoin);
paint.setStrokeMiter(mStrokeMiterlimit * mScale);
paint.setStrokeWidth(mStrokeWidth * mScale);
setupPaint(paint, opacity, mStrokeColor, box);
if (mStrokeDasharray != null && mStrokeDasharray.length > 0) {
paint.setPathEffect(new DashPathEffect(mStrokeDasharray, mStrokeDashoffset));
}
return true;
}
示例7: setPaintParam
import android.graphics.DashPathEffect; //导入依赖的package包/类
public void setPaintParam(int color, int paintWidth, int style) {
mPaint.setStrokeWidth(paintWidth);
mPaint.setColor(color);
mPaint.setAntiAlias(true);
switch (style) {
case STYLE_DASH:
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setPathEffect(new DashPathEffect(mBase.mDashEffect, 1));
this.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
break;
case STYLE_SOLID:
mPaint.setStyle(Paint.Style.FILL);
break;
}
}
示例8: applyDashPatternIfNeeded
import android.graphics.DashPathEffect; //导入依赖的package包/类
private void applyDashPatternIfNeeded() {
if (dashPatternAnimations.isEmpty()) {
return;
}
float scale = lottieDrawable.getScale();
for (int i = 0; i < dashPatternAnimations.size(); i++) {
dashPatternValues[i] = dashPatternAnimations.get(i).getValue();
// If the value of the dash pattern or gap is too small, the number of individual sections
// approaches infinity as the value approaches 0.
// To mitigate this, we essentially put a minimum value on the dash pattern size of 1px
// and a minimum gap size of 0.01.
if (i % 2 == 0) {
if (dashPatternValues[i] < 1f) {
dashPatternValues[i] = 1f;
}
} else {
if (dashPatternValues[i] < 0.1f) {
dashPatternValues[i] = 0.1f;
}
}
dashPatternValues[i] *= scale;
}
float offset = dashPatternOffsetAnimation == null ? 0f : dashPatternOffsetAnimation.getValue();
paint.setPathEffect(new DashPathEffect(dashPatternValues, offset));
}
示例9: onDraw
import android.graphics.DashPathEffect; //导入依赖的package包/类
@[email protected]("DrawAllocation")
protected final void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isInEditMode()) {//这段代码在运行时不会执行,只会在Studio编辑预览时运行,不用在意性能问题
int d = DensityUtil.dp2px(5);
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setColor(0x44ffffff);
paint.setStrokeWidth(DensityUtil.dp2px(1));
paint.setPathEffect(new DashPathEffect(new float[]{d, d, d, d}, 1));
canvas.drawRect(d, d, getWidth() - d, getBottom() - d, paint);
TextView textView = new TextView(getContext());
textView.setText(getClass().getSimpleName()+" 虚假区域\n运行时代表下拉Header的高度【" + DensityUtil.px2dp(getHeight()) + "dp】\n而不会显示任何东西");
textView.setTextColor(0x44ffffff);
textView.setGravity(Gravity.CENTER);
textView.measure(makeMeasureSpec(getWidth(), EXACTLY), makeMeasureSpec(getHeight(), EXACTLY));
textView.layout(0, 0, getWidth(), getHeight());
textView.draw(canvas);
}
}
示例10: onDraw
import android.graphics.DashPathEffect; //导入依赖的package包/类
@Override protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//无效果
mEffects[0] = null;
//拐角处变得圆滑
mEffects[1] = new CornerPathEffect(30);
//线段上就会产生许多杂点
mEffects[2] = new DiscretePathEffect(3.0F, 5.0F);
//绘制虚线
mEffects[3] = new DashPathEffect(new float[] { 20, 10, 5, 10 }, 0);
Path path = new Path();
path.addRect(0, 0, 8, 8, Path.Direction.CCW);
//设置点的图形,即方形点的虚线,圆形点的虚线
mEffects[4] = new PathDashPathEffect(path, 12, 0, PathDashPathEffect.Style.ROTATE);
//组合PathEffect
mEffects[5] = new ComposePathEffect(mEffects[3], mEffects[1]);
for (int i = 0; i < mEffects.length; i++) {
mPaint.setPathEffect(mEffects[i]);
canvas.drawPath(mPath, mPaint);
canvas.translate(0, 200);
}
}
示例11: getTargetLine
import android.graphics.DashPathEffect; //导入依赖的package包/类
private Line getTargetLine() {
if (!needDrawTargetLine()) {
return null;
}
PointValue lastRecordPoint = (PointValue) this.mPointValues.get(this.mPointValues.size()
- 1);
PointValue targetPoint = new PointValue(((AxisValue) this.mAxisValues.get(this
.mAxisValues.size() - 1)).getValue(), this.mTargetWeight);
List<PointValue> points = new ArrayList();
points.add(lastRecordPoint);
points.add(targetPoint);
Line line = new Line(points);
line.setColor(this.resources.getColor(R.color.da));
line.setPathEffect(new DashPathEffect(new float[]{15.0f, 15.0f, 15.0f, 15.0f}, 0.0f));
line.setHasLabels(false);
if (this.mTypeMode > 0) {
line.setHasPoints(false);
return line;
}
line.setHasPoints(true);
return line;
}
示例12: init
import android.graphics.DashPathEffect; //导入依赖的package包/类
private void init(Context context) {
setLayerType(1, null);
this.mContext = context;
this.mBackgroundPaint = new Paint();
this.mBackgroundPaint.setStrokeWidth(2.0f);
this.mBackgroundPaint.setAntiAlias(true);
this.mBackgroundPaint.setColor(-5056771);
this.mBackgroundPaint.setStyle(Style.STROKE);
this.mColumnPaint = new Paint();
this.mColumnPaint.setAntiAlias(true);
this.mColumnPaint.setStyle(Style.FILL);
this.mColumnPaint.setColor(-12477447);
this.mLinePaint = new Paint();
this.mLinePaint.setAntiAlias(true);
this.mLinePaint.setStyle(Style.STROKE);
this.mLinePaint.setColor(-5056771);
this.mLinePaint.setStrokeWidth(1.0f);
this.mLinePaint.setPathEffect(new DashPathEffect(new float[]{aj.hA, aj.hA}, 0.0f));
this.mBackgroundRect = new RectF();
}
示例13: WidgetTextFrame
import android.graphics.DashPathEffect; //导入依赖的package包/类
public WidgetTextFrame(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
setClipChildren(false);
setClipToPadding(false);
mContext = context.getApplicationContext();
mPaddingSpace = context.getResources().getDimensionPixelSize(R.dimen.edit_text_space);
mRoundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
PathEffect effect = new DashPathEffect(new float[]{20, 20}, 1);
mRoundPaint.setAntiAlias(true);
mRoundPaint.setColor(getResources().getColor(R.color.edit_text_background_color));
mRoundPaint.setPathEffect(effect);
mRoundPaint.setStyle(Paint.Style.STROKE);
mRoundPaint.setStrokeWidth(3);
mDeletePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mDeletePaint.setAntiAlias(true);
mDeletePaint.setFilterBitmap(true);
mDeletePaint.setDither(true);
setWillNotDraw(false);
}
示例14: initPaint
import android.graphics.DashPathEffect; //导入依赖的package包/类
private void initPaint() {
mPaint = new Paint();
mPaint.setColor(mColor);
mPaint.setStyle(Paint.Style.STROKE);
/** 边界实际的位置是在边框的中间,所以都要减去边框宽度的一半,所以需要乘以2,才能得到想要的尺寸*/
mPaint.setStrokeWidth(mThickness * 2);
if (mLineMode == LINE_MODE_DOTTED) {
/** 定义 虚线的一些尺寸属性 从0开始,偶数项代表 单个虚线的长度,第二个代表虚线间隔的大小,后面会依次循环*/
float[] intervals = new float[]{mDottedSize, mDottedSpacingSize};
/** 第二个参数是 偏移量,填0就够用了*/
DashPathEffect dashPathEffect = new DashPathEffect(intervals, 0);
mPaint.setPathEffect(dashPathEffect);
}
mPath = new Path();
}
示例15: onDraw
import android.graphics.DashPathEffect; //导入依赖的package包/类
@Override
@SuppressLint({"DrawAllocation", "SetTextI18n"})
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isInEditMode()) {//这段代码在运行时不会执行,只会在Studio编辑预览时运行,不用在意性能问题
int d = DensityUtil.dp2px(5);
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setColor(0x44ffffff);
paint.setStrokeWidth(DensityUtil.dp2px(1));
paint.setPathEffect(new DashPathEffect(new float[]{d, d, d, d}, 1));
canvas.drawRect(d, d, getWidth() - d, getBottom() - d, paint);
TextView textView = new TextView(getContext());
textView.setText(getClass().getSimpleName()+" 虚假区域\n运行时代表下拉Header的高度【" + DensityUtil.px2dp(getHeight()) + "dp】\n而不会显示任何东西");
textView.setTextColor(0x44ffffff);
textView.setGravity(Gravity.CENTER);
textView.measure(makeMeasureSpec(getWidth(), EXACTLY), makeMeasureSpec(getHeight(), EXACTLY));
textView.layout(0, 0, getWidth(), getHeight());
textView.draw(canvas);
}
}