透明蒙层
1. 滑出阴影
private void drawShadowVertical(Canvas canvas, int top, int bottom, int dX) {
final GradientDrawable.Orientation orientation = dX > 0 ? GradientDrawable.Orientation.RIGHT_LEFT : GradientDrawable.Orientation.LEFT_RIGHT;
final int[] colors = new int[]{0x20000000, 0x00000000};
final GradientDrawable gradient = new GradientDrawable(orientation, colors);
gradient.setGradientType(GradientDrawable.LINEAR_GRADIENT);
gradient.setDither(true);
if (dX > 0) {
gradient.setBounds(dX - 48, top, dX, bottom);
} else {
gradient.setBounds(myWidth + dX, top, myWidth + dX + 48, bottom);
}
gradient.draw(canvas);
}Last updated
Was this helpful?