add:观众滑动右侧半透明效果
This commit is contained in:
parent
6d9fd4e0a8
commit
cfcad83328
@ -26,20 +26,22 @@ public class RightGradual extends RecyclerView.ItemDecoration {
|
|||||||
public RightGradual() {
|
public RightGradual() {
|
||||||
mPaint = new Paint();
|
mPaint = new Paint();
|
||||||
mXfermode = new PorterDuffXfermode(PorterDuff.Mode.DST_IN);
|
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
|
@Override
|
||||||
public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
|
public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
|
||||||
super.onDrawOver(canvas, parent, 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 top=0f;
|
||||||
float right=parent.getRight();
|
float right=parent.getRight();
|
||||||
float bottom=parent.getBottom();
|
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.setXfermode(mXfermode);
|
||||||
mPaint.setShader(mLinearGradient);
|
mPaint.setShader(mLinearGradient);
|
||||||
//mPaint.setColor(Color.BLUE);
|
//mPaint.setColor(Color.BLUE);
|
||||||
System.out.println("left = "+left+" right = "+right+" bottom = "+bottom);
|
|
||||||
canvas.drawRect(left, top,right, bottom, mPaint);
|
canvas.drawRect(left, top,right, bottom, mPaint);
|
||||||
mPaint.setXfermode(null);
|
mPaint.setXfermode(null);
|
||||||
canvas.restoreToCount(mLayerId);
|
canvas.restoreToCount(mLayerId);
|
||||||
|
Loading…
Reference in New Issue
Block a user