@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);
}
}
FalsifyHeader.java 文件源码
java
阅读 36
收藏 0
点赞 0
评论 0
项目:SmartRefreshLayout
作者:
评论列表
文章目录