FalsifyFooter.java 文件源码

java
阅读 39 收藏 0 点赞 0 评论 0

项目:Rxjava2.0Demo 作者:
@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);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号