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);