public class GradientLayout extends View {
private Paint mPaint;
private Shader mShader;
private Bitmap mBitmap;
public GradientLayout(Context context) {
this(context, null);
}
public GradientLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public GradientLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init() {
mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.beauty);
mPaint = new Paint(); //初始化
// mPaint.setColor(Color.RED);// 设置颜色
// mPaint.setARGB(255, 255, 255, 0); // 设置 Paint对象颜色,范围为0~255
// mPaint.setAlpha(200); // 设置alpha不透明度,范围为0~255
mPaint.setAntiAlias(true); // 抗锯齿
mPaint.setStyle(Paint.Style.FILL); //描边效果
// mPaint.setStrokeWidth(4);//描边宽度
// mPaint.setStrokeCap(Paint.Cap.ROU