public class TranslucentView extends View {
public TranslucentView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint paint = new Paint();
LinearGradient linearGradient = new LinearGradient(0, 0, 0, getMeasuredHeight(), new int[]{ Color.parseColor("#D7FFFFFF"),Color.parseColor("#D7FFFFFF"),Color.parseColor("#00ffffff")}, null, LinearGradient.TileMode.CLAMP);
paint.setShader(linearGradient);
canvas.drawRect(0, 0, getMeasuredWidth(), getMeasuredHeight(), paint);
}
}
这是一个从上到下从白色变透明的view 我这样写好了以后,把它盖在一个紫色的背景下发现这个view在简便的过程中出现了一条白色,这个是什么原因导致的呢?