bitmap画向左---右的按钮

来源:互联网 发布:淘宝店怎样提高信誉 编辑:程序博客网 时间:2024/05/22 02:23
private Bitmap getLeftIcon() {
Shader gradient = new LinearGradient(0, 0, height >> 

1, 0, new int[] {
Color.rgb(180, 196, 219), Color.rgb

(231, 240, 245) }, null,
TileMode.REPEAT);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setShader(gradient);
Bitmap bitmap = Bitmap.createBitmap(height, height, 

Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.drawCircle(height >> 1, height >> 1, height 

>> 1, paint);
paint.setShader(null);
paint.setColor(Color.WHITE);
paint.setAlpha(255);
canvas.drawCircle(height >> 2, height >> 1, 0.15f * 

height, paint);
paint.setColor(Color.RED);
Path path = new Path();
path.moveTo(height >> 3, height >> 1);
path.lineTo(0.325f * height, 0.4f * height);
path.lineTo(0.325f * height, 0.6f * height);
path.close();
canvas.drawPath(path, paint);
return Bitmap.createBitmap(bitmap, 0, 0, height >> 

1, height);
}



/**
 * 获取右边指示钮的bitmap
 * 
 * @return
 */
private Bitmap getRightIcon() {
//可以旋转的
Matrix m = new Matrix();
//位置旋转180度
m.postRotate(180);
Bitmap bitmap = getLeftIcon();
//给左边的bitmap添加旋转对象
return Bitmap.createBitmap(bitmap, 0, 0, height >> 

1, height, m, false);
}
原创粉丝点击