From cfcad8332838cc991abc45f5b5eb312d7d2b283d Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Tue, 23 Aug 2022 13:11:55 +0800 Subject: [PATCH] =?UTF-8?q?add:=E8=A7=82=E4=BC=97=E6=BB=91=E5=8A=A8?= =?UTF-8?q?=E5=8F=B3=E4=BE=A7=E5=8D=8A=E9=80=8F=E6=98=8E=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/yunbao/live/custom/RightGradual.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/custom/RightGradual.java b/live/src/main/java/com/yunbao/live/custom/RightGradual.java index 6c47543ed..01b6ef5e1 100644 --- a/live/src/main/java/com/yunbao/live/custom/RightGradual.java +++ b/live/src/main/java/com/yunbao/live/custom/RightGradual.java @@ -26,20 +26,22 @@ public class RightGradual extends RecyclerView.ItemDecoration { public RightGradual() { mPaint = new Paint(); mXfermode = new PorterDuffXfermode(PorterDuff.Mode.DST_IN); - mLinearGradient = new LinearGradient(0.0f, 0.0f, 0.0f, 10.0f, new int[]{0, Color.BLACK}, null, Shader.TileMode.CLAMP); + mLinearGradient = null; } @Override public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) { super.onDrawOver(canvas, parent, state); - float left=parent.getRight()-parent.getRight()/2f; + float left=parent.getRight()-parent.getRight()/0.1f; float top=0f; float right=parent.getRight(); float bottom=parent.getBottom(); + if(mLinearGradient==null){ + mLinearGradient=new LinearGradient(parent.getMeasuredWidth(), 0.0f, 0.0f, 0.0f, new int[]{0, Color.BLACK}, new float[]{0.0f,0.2f}, Shader.TileMode.CLAMP); + } mPaint.setXfermode(mXfermode); mPaint.setShader(mLinearGradient); //mPaint.setColor(Color.BLUE); - System.out.println("left = "+left+" right = "+right+" bottom = "+bottom); canvas.drawRect(left, top,right, bottom, mPaint); mPaint.setXfermode(null); canvas.restoreToCount(mLayerId);