本文整理汇总了Java中android.graphics.drawable.ShapeDrawable.setBounds方法的典型用法代码示例。如果您正苦于以下问题:Java ShapeDrawable.setBounds方法的具体用法?Java ShapeDrawable.setBounds怎么用?Java ShapeDrawable.setBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.drawable.ShapeDrawable
的用法示例。
在下文中一共展示了ShapeDrawable.setBounds方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: roundBitmap
import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
public static Bitmap roundBitmap(Bitmap bitmap, int i, int i2, float f, float f2, float f3,
float f4) throws Throwable {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
Rect rect = new Rect(0, 0, width, height);
Bitmap createBitmap = (width == i && height == i2) ? Bitmap.createBitmap(bitmap.getWidth
(), bitmap.getHeight(), Config.ARGB_8888) : Bitmap.createBitmap(i, i2, Config
.ARGB_8888);
Canvas canvas = new Canvas(createBitmap);
Paint paint = new Paint();
Rect rect2 = new Rect(0, 0, i, i2);
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(-12434878);
float[] fArr = new float[]{f, f, f2, f2, f3, f3, f4, f4};
ShapeDrawable shapeDrawable = new ShapeDrawable(new RoundRectShape(fArr, new RectF(0.0f,
0.0f, 0.0f, 0.0f), fArr));
shapeDrawable.setBounds(rect2);
shapeDrawable.draw(canvas);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect2, paint);
return createBitmap;
}
示例2: MagnifierView
import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
public MagnifierView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.pic)).getBitmap();
scaledBitmap = Bitmap.createScaledBitmap(bitmap, bitmap.getWidth() * FACTOR, bitmap.getHeight() * FACTOR,
true);
// bitmap.recycle();
mBitmapShader = new BitmapShader(scaledBitmap,
Shader.TileMode.CLAMP,
Shader.TileMode.CLAMP);
mShapeDrawable = new ShapeDrawable(new OvalShape());
mShapeDrawable.setBounds(0, 0, WIDTH, WIDTH);
mShapeDrawable.getPaint().setShader(mBitmapShader);
mMatrix = new Matrix();
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setColor(Color.RED);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(3);
}
示例3: buildColorPickerView
import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
private void buildColorPickerView(View view, int colorCode) {
view.setVisibility(View.VISIBLE);
ShapeDrawable biggerCircle = new ShapeDrawable(new OvalShape());
biggerCircle.setIntrinsicHeight(20);
biggerCircle.setIntrinsicWidth(20);
biggerCircle.setBounds(new Rect(0, 0, 20, 20));
biggerCircle.getPaint().setColor(colorCode);
ShapeDrawable smallerCircle = new ShapeDrawable(new OvalShape());
smallerCircle.setIntrinsicHeight(5);
smallerCircle.setIntrinsicWidth(5);
smallerCircle.setBounds(new Rect(0, 0, 5, 5));
smallerCircle.getPaint().setColor(Color.WHITE);
smallerCircle.setPadding(10, 10, 10, 10);
Drawable[] drawables = {smallerCircle, biggerCircle};
LayerDrawable layerDrawable = new LayerDrawable(drawables);
view.setBackgroundDrawable(layerDrawable);
}
示例4: Colorize
import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void Colorize() {
for (int i = 0; i < buttons.size(); i++) {
ShapeDrawable d = new ShapeDrawable(new OvalShape());
d.setBounds(58, 58, 58, 58);
Log.e("Shape drown no", i + "");
buttons.get(i).setVisibility(View.INVISIBLE);
d.getPaint().setStyle(Paint.Style.FILL);
d.getPaint().setColor(colors.get(i));
buttons.get(i).setBackground(d);
}
animate();
}
示例5: ColorizeOld
import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
private void ColorizeOld() {
for (int i = 0; i < buttons.size(); i++) {
ShapeDrawable d = new ShapeDrawable(new OvalShape());
d.getPaint().setColor(colors.get(i));
d.getPaint().setStrokeWidth(1f);
d.setBounds(58, 58, 58, 58);
buttons.get(i).setVisibility(View.INVISIBLE);
d.getPaint().setStyle(Paint.Style.FILL);
d.getPaint().setColor(colors.get(i));
buttons.get(i).setBackgroundDrawable(d);
}
animate();
}
示例6: Oval
import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
public Oval(float x,float y, float ray, int color, Context cont) {
super(cont);
this.x=x;
this.y=y;
this.ray=ray;
int[] colors = {0xffffffff,color&0xddffffff,color};
float[] stops = {0.9f, 0.95f,0.945f};
mDrawable = new ShapeDrawable(new OvalShape());
mDrawable.setBounds((int)(x-ray),(int)(y-ray),(int)(x+ray),(int)(y+ray));
mDrawable.getPaint().setColor(color);
mDrawable.getPaint().setShader(new RadialGradient(ray,ray,ray, colors, stops, Shader.TileMode.MIRROR ));
}
示例7: studyBitmapShader
import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
/**
* 位图图像渲染
* @param canvas
*/
private void studyBitmapShader(Canvas canvas) {
//创建BitmapShader
//其中TileMode.MIRROR x方向镜像 TileMode.REPEAT y方向重复
mBitmapShader = new BitmapShader(mBitMap, Shader.TileMode.MIRROR, Shader.TileMode.REPEAT);
//创建矩阵 来缩放图片
Matrix matrix = new Matrix();
matrix.setScale(0.2f,0.2f);
mBitmapShader.setLocalMatrix(matrix);
mPaint.setAntiAlias(true);
mPaint.setShader(mBitmapShader);
//画圆形的图片
// canvas.drawCircle(mBitMap.getWidth()/2,mBitMap.getHeight()/2,300,mPaint);
//画矩形的图片
// Rect rect = new Rect(0,0,600,600);
// canvas.drawRect(rect,mPaint);
//
//画椭圆的图片
// RectF rectf = new RectF(0,0,400,300);
//
// canvas.drawOval(rectf,mPaint);
//用shapeDrawable 实现圆形图片
ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());
shapeDrawable.getPaint().setShader(mBitmapShader);
shapeDrawable.setBounds(0,0,400,400);
shapeDrawable.draw(canvas);
}
示例8: MyZoomImageView
import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
public MyZoomImageView(Context context) {
super(context);
mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.meinv);
mBitmapScale = mBitmap;
mBitmapScale = Bitmap.createScaledBitmap(mBitmapScale,mBitmap.getWidth() * FACTOR ,mBitmap.getHeight()*FACTOR,true);
mBitmapShader = new BitmapShader(mBitmapScale, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
matrix = new Matrix();
shapeDrawable = new ShapeDrawable(new OvalShape());
shapeDrawable.getPaint().setShader(mBitmapShader);
shapeDrawable.setBounds(0,0,RADIUS * 2,RADIUS * 2);
}