android.graphics.drawable.shapes.OvalShape#resize()源码实例Demo

下面列出了android.graphics.drawable.shapes.OvalShape#resize() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private Bitmap getLargeNotificationIcon(Bitmap bitmap) {
    Resources resources = mContext.getResources();
    int height = (int) resources.getDimension(android.R.dimen.notification_large_icon_height);
    int width = (int) resources.getDimension(android.R.dimen.notification_large_icon_width);
    final OvalShape circle = new OvalShape();
    circle.resize(width, height);
    final Paint paint = new Paint();
    paint.setColor(ApiCompatibilityUtils.getColor(resources, R.color.google_blue_grey_500));

    final Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(result);
    circle.draw(canvas, paint);
    float leftOffset = (width - bitmap.getWidth()) / 2f;
    float topOffset = (height - bitmap.getHeight()) / 2f;
    if (leftOffset >= 0 && topOffset >= 0) {
        canvas.drawBitmap(bitmap, leftOffset, topOffset, null);
    } else {
        // Scale down the icon into the notification icon dimensions
        canvas.drawBitmap(bitmap,
                new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()),
                new Rect(0, 0, width, height),
                null);
    }
    return result;
}
 
源代码2 项目: 365browser   文件: DownloadNotificationService.java
private Bitmap getLargeNotificationIcon(Bitmap bitmap) {
    Resources resources = mContext.getResources();
    int height = (int) resources.getDimension(android.R.dimen.notification_large_icon_height);
    int width = (int) resources.getDimension(android.R.dimen.notification_large_icon_width);
    final OvalShape circle = new OvalShape();
    circle.resize(width, height);
    final Paint paint = new Paint();
    paint.setColor(ApiCompatibilityUtils.getColor(resources, R.color.google_blue_grey_500));

    final Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(result);
    circle.draw(canvas, paint);
    float leftOffset = (width - bitmap.getWidth()) / 2f;
    float topOffset = (height - bitmap.getHeight()) / 2f;
    if (leftOffset >= 0 && topOffset >= 0) {
        canvas.drawBitmap(bitmap, leftOffset, topOffset, null);
    } else {
        // Scale down the icon into the notification icon dimensions
        canvas.drawBitmap(bitmap,
                new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()),
                new Rect(0, 0, width, height),
                null);
    }
    return result;
}
 
源代码3 项目: codeexamples-android   文件: CustomEvaluator.java
private ShapeHolder createBall(float x, float y) {
    OvalShape circle = new OvalShape();
    circle.resize(50f, 50f);
    ShapeDrawable drawable = new ShapeDrawable(circle);
    ShapeHolder shapeHolder = new ShapeHolder(drawable);
    shapeHolder.setX(x - 25f);
    shapeHolder.setY(y - 25f);
    int red = (int)(Math.random() * 255);
    int green = (int)(Math.random() * 255);
    int blue = (int)(Math.random() * 255);
    int color = 0xff000000 | red << 16 | green << 8 | blue;
    Paint paint = drawable.getPaint(); //new Paint(Paint.ANTI_ALIAS_FLAG);
    int darkColor = 0xff000000 | red/4 << 16 | green/4 << 8 | blue/4;
    RadialGradient gradient = new RadialGradient(37.5f, 12.5f,
            50f, color, darkColor, Shader.TileMode.CLAMP);
    paint.setShader(gradient);
    shapeHolder.setPaint(paint);
    return shapeHolder;
}
 
源代码4 项目: codeexamples-android   文件: AnimationCloning.java
private ShapeHolder addBall(float x, float y) {
    OvalShape circle = new OvalShape();
    circle.resize(50f * mDensity, 50f * mDensity);
    ShapeDrawable drawable = new ShapeDrawable(circle);
    ShapeHolder shapeHolder = new ShapeHolder(drawable);
    shapeHolder.setX(x - 25f);
    shapeHolder.setY(y - 25f);
    int red = (int)(100 + Math.random() * 155);
    int green = (int)(100 + Math.random() * 155);
    int blue = (int)(100 + Math.random() * 155);
    int color = 0xff000000 | red << 16 | green << 8 | blue;
    Paint paint = drawable.getPaint(); //new Paint(Paint.ANTI_ALIAS_FLAG);
    int darkColor = 0xff000000 | red/4 << 16 | green/4 << 8 | blue/4;
    RadialGradient gradient = new RadialGradient(37.5f, 12.5f,
            50f, color, darkColor, Shader.TileMode.CLAMP);
    paint.setShader(gradient);
    shapeHolder.setPaint(paint);
    balls.add(shapeHolder);
    return shapeHolder;
}
 
源代码5 项目: codeexamples-android   文件: BouncingBalls.java
private ShapeHolder addBall(float x, float y) {
    OvalShape circle = new OvalShape();
    circle.resize(50f, 50f);
    ShapeDrawable drawable = new ShapeDrawable(circle);
    ShapeHolder shapeHolder = new ShapeHolder(drawable);
    shapeHolder.setX(x - 25f);
    shapeHolder.setY(y - 25f);
    int red = (int)(Math.random() * 255);
    int green = (int)(Math.random() * 255);
    int blue = (int)(Math.random() * 255);
    int color = 0xff000000 | red << 16 | green << 8 | blue;
    Paint paint = drawable.getPaint(); //new Paint(Paint.ANTI_ALIAS_FLAG);
    int darkColor = 0xff000000 | red/4 << 16 | green/4 << 8 | blue/4;
    RadialGradient gradient = new RadialGradient(37.5f, 12.5f,
            50f, color, darkColor, Shader.TileMode.CLAMP);
    paint.setShader(gradient);
    shapeHolder.setPaint(paint);
    balls.add(shapeHolder);
    return shapeHolder;
}
 
源代码6 项目: codeexamples-android   文件: AnimationSeeking.java
private ShapeHolder addBall(float x, float y) {
    OvalShape circle = new OvalShape();
    circle.resize(BALL_SIZE, BALL_SIZE);
    ShapeDrawable drawable = new ShapeDrawable(circle);
    ShapeHolder shapeHolder = new ShapeHolder(drawable);
    shapeHolder.setX(x);
    shapeHolder.setY(y);
    int red = (int)(100 + Math.random() * 155);
    int green = (int)(100 + Math.random() * 155);
    int blue = (int)(100 + Math.random() * 155);
    int color = 0xff000000 | red << 16 | green << 8 | blue;
    Paint paint = drawable.getPaint();
    int darkColor = 0xff000000 | red/4 << 16 | green/4 << 8 | blue/4;
    RadialGradient gradient = new RadialGradient(37.5f, 12.5f,
            50f, color, darkColor, Shader.TileMode.CLAMP);
    paint.setShader(gradient);
    shapeHolder.setPaint(paint);
    balls.add(shapeHolder);
    return shapeHolder;
}
 
源代码7 项目: codeexamples-android   文件: ReversingAnimation.java
private ShapeHolder createBall(float x, float y) {
    OvalShape circle = new OvalShape();
    circle.resize(50f, 50f);
    ShapeDrawable drawable = new ShapeDrawable(circle);
    ShapeHolder shapeHolder = new ShapeHolder(drawable);
    shapeHolder.setX(x - 25f);
    shapeHolder.setY(y - 25f);
    int red = (int)(Math.random() * 255);
    int green = (int)(Math.random() * 255);
    int blue = (int)(Math.random() * 255);
    int color = 0xff000000 | red << 16 | green << 8 | blue;
    Paint paint = drawable.getPaint(); //new Paint(Paint.ANTI_ALIAS_FLAG);
    int darkColor = 0xff000000 | red/4 << 16 | green/4 << 8 | blue/4;
    RadialGradient gradient = new RadialGradient(37.5f, 12.5f,
            50f, color, darkColor, Shader.TileMode.CLAMP);
    paint.setShader(gradient);
    shapeHolder.setPaint(paint);
    return shapeHolder;
}
 
private ShapeHolder addBall(float x, float y) {
    OvalShape circle = new OvalShape();
    circle.resize(BALL_SIZE, BALL_SIZE);
    ShapeDrawable drawable = new ShapeDrawable(circle);
    ShapeHolder shapeHolder = new ShapeHolder(drawable);
    shapeHolder.setX(x);
    shapeHolder.setY(y);
    int red = (int)(100 + Math.random() * 155);
    int green = (int)(100 + Math.random() * 155);
    int blue = (int)(100 + Math.random() * 155);
    int color = 0xff000000 | red << 16 | green << 8 | blue;
    Paint paint = drawable.getPaint();
    int darkColor = 0xff000000 | red/4 << 16 | green/4 << 8 | blue/4;
    RadialGradient gradient = new RadialGradient(37.5f, 12.5f,
            50f, color, darkColor, Shader.TileMode.CLAMP);
    paint.setShader(gradient);
    shapeHolder.setPaint(paint);
    balls.add(shapeHolder);
    return shapeHolder;
}
 
源代码9 项目: codeexamples-android   文件: AnimatorEvents.java
private ShapeHolder createBall(float x, float y) {
    OvalShape circle = new OvalShape();
    circle.resize(50f, 50f);
    ShapeDrawable drawable = new ShapeDrawable(circle);
    ShapeHolder shapeHolder = new ShapeHolder(drawable);
    shapeHolder.setX(x - 25f);
    shapeHolder.setY(y - 25f);
    int red = (int)(Math.random() * 255);
    int green = (int)(Math.random() * 255);
    int blue = (int)(Math.random() * 255);
    int color = 0xff000000 | red << 16 | green << 8 | blue;
    Paint paint = drawable.getPaint(); //new Paint(Paint.ANTI_ALIAS_FLAG);
    int darkColor = 0xff000000 | red/4 << 16 | green/4 << 8 | blue/4;
    RadialGradient gradient = new RadialGradient(37.5f, 12.5f,
            50f, color, darkColor, Shader.TileMode.CLAMP);
    paint.setShader(gradient);
    shapeHolder.setPaint(paint);
    return shapeHolder;
}
 
源代码10 项目: AnimationApiDemos   文件: CustomEvaluator.java
private ShapeHolder createBall(float x, float y) {
	OvalShape circle = new OvalShape();
	circle.resize(50f, 50f);
	ShapeDrawable drawable = new ShapeDrawable(circle);
	ShapeHolder shapeHolder = new ShapeHolder(drawable);
	shapeHolder.setX(x - 25f);
	shapeHolder.setY(y - 25f);
	int red = (int) (Math.random() * 255);
	int green = (int) (Math.random() * 255);
	int blue = (int) (Math.random() * 255);
	int color = 0xff000000 | red << 16 | green << 8 | blue;
	Paint paint = drawable.getPaint(); // new
										// Paint(Paint.ANTI_ALIAS_FLAG);
	int darkColor = 0xff000000 | red / 4 << 16 | green / 4 << 8 | blue
			/ 4;
	RadialGradient gradient = new RadialGradient(37.5f, 12.5f, 50f,
			color, darkColor, Shader.TileMode.CLAMP);
	paint.setShader(gradient);
	shapeHolder.setPaint(paint);
	return shapeHolder;
}
 
源代码11 项目: AnimationApiDemos   文件: BouncingBalls.java
private ShapeHolder addBall(float x, float y) {
	OvalShape circle = new OvalShape();
	circle.resize(50f, 50f);
	ShapeDrawable drawable = new ShapeDrawable(circle);
	ShapeHolder shapeHolder = new ShapeHolder(drawable);
	shapeHolder.setX(x - 25f);
	shapeHolder.setY(y - 25f);
	int red = (int) (Math.random() * 255);
	int green = (int) (Math.random() * 255);
	int blue = (int) (Math.random() * 255);
	int color = 0xff000000 | red << 16 | green << 8 | blue;
	Paint paint = drawable.getPaint(); // new
										// Paint(Paint.ANTI_ALIAS_FLAG);
	int darkColor = 0xff000000 | red / 4 << 16 | green / 4 << 8 | blue
			/ 4;
	RadialGradient gradient = new RadialGradient(37.5f, 12.5f, 50f,
			color, darkColor, Shader.TileMode.CLAMP);
	paint.setShader(gradient);
	shapeHolder.setPaint(paint);
	balls.add(shapeHolder);
	return shapeHolder;
}
 
源代码12 项目: AnimationApiDemos   文件: MultiPropertyAnimation.java
private ShapeHolder addBall(float x, float y) {
	OvalShape circle = new OvalShape();
	circle.resize(BALL_SIZE, BALL_SIZE);
	ShapeDrawable drawable = new ShapeDrawable(circle);
	ShapeHolder shapeHolder = new ShapeHolder(drawable);
	shapeHolder.setX(x);
	shapeHolder.setY(y);
	int red = (int) (100 + Math.random() * 155);
	int green = (int) (100 + Math.random() * 155);
	int blue = (int) (100 + Math.random() * 155);
	int color = 0xff000000 | red << 16 | green << 8 | blue;
	Paint paint = drawable.getPaint();
	int darkColor = 0xff000000 | red / 4 << 16 | green / 4 << 8 | blue
			/ 4;
	RadialGradient gradient = new RadialGradient(37.5f, 12.5f, 50f,
			color, darkColor, Shader.TileMode.CLAMP);
	paint.setShader(gradient);
	shapeHolder.setPaint(paint);
	balls.add(shapeHolder);
	return shapeHolder;
}
 
源代码13 项目: AnimationApiDemos   文件: BasicAnimationActivity.java
private ShapeHolder addBall(float x, float y) {
	OvalShape circle = new OvalShape();
	circle.resize(50f * mDensity, 50f * mDensity);
	ShapeDrawable drawable = new ShapeDrawable(circle);
	ShapeHolder shapeHolder = new ShapeHolder(drawable);
	shapeHolder.setX(x - 25f);
	shapeHolder.setY(y - 25f);
	int red = (int) (100 + Math.random() * 155);
	int green = (int) (100 + Math.random() * 155);
	int blue = (int) (100 + Math.random() * 155);
	int color = 0xff000000 | red << 16 | green << 8 | blue;
	Paint paint = drawable.getPaint(); // new
										// Paint(Paint.ANTI_ALIAS_FLAG);
	int darkColor = 0xff000000 | red / 4 << 16 | green / 4 << 8 | blue
			/ 4;
	RadialGradient gradient = new RadialGradient(37.5f, 12.5f, 50f,
			color, darkColor, Shader.TileMode.CLAMP);
	paint.setShader(gradient);
	shapeHolder.setPaint(paint);
	balls.add(shapeHolder);
	return shapeHolder;
}
 
源代码14 项目: Memory-capsule   文件: MonthView.java
private BGCircle createCircle(float x, float y) {
    OvalShape circle = new OvalShape();
    circle.resize(0, 0);
    ShapeDrawable drawable = new ShapeDrawable(circle);
    BGCircle circle1 = new BGCircle(drawable);
    circle1.setX(x);
    circle1.setY(y);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        circle1.setRadius(circleRadius);
    }
    drawable.getPaint().setColor(mTManager.colorBGCircle());
    return circle1;
}
 
源代码15 项目: SignCalender   文件: MonthView.java
private BGCircle createCircle(float x, float y) {
    OvalShape circle = new OvalShape();
    circle.resize(0, 0);
    ShapeDrawable drawable = new ShapeDrawable(circle);
    BGCircle circle1 = new BGCircle(drawable);
    circle1.setX(x);
    circle1.setY(y);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        circle1.setRadius(circleRadius);
    }
    drawable.getPaint().setColor(mTManager.colorBGCircle());
    return circle1;
}
 
源代码16 项目: nono-android   文件: MonthView.java
private BGCircle createCircle(float x, float y) {
    OvalShape circle = new OvalShape();
    circle.resize(0, 0);
    ShapeDrawable drawable = new ShapeDrawable(circle);
    BGCircle circle1 = new BGCircle(drawable);
    circle1.setX(x);
    circle1.setY(y);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        circle1.setRadius(circleRadius);
    }
    drawable.getPaint().setColor(mTManager.colorBGCircle());
    return circle1;
}
 
源代码17 项目: DatePicker   文件: MonthView.java
private BGCircle createCircle(float x, float y) {
    OvalShape circle = new OvalShape();
    circle.resize(0, 0);
    ShapeDrawable drawable = new ShapeDrawable(circle);
    BGCircle circle1 = new BGCircle(drawable);
    circle1.setX(x);
    circle1.setY(y);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        circle1.setRadius(circleRadius);
    }
    drawable.getPaint().setColor(mTManager.colorBGCircle());
    return circle1;
}
 
源代码18 项目: codeexamples-android   文件: AnimationLoading.java
private ShapeHolder createBall(float x, float y) {
    OvalShape circle = new OvalShape();
    circle.resize(BALL_SIZE, BALL_SIZE);
    ShapeDrawable drawable = new ShapeDrawable(circle);
    ShapeHolder shapeHolder = new ShapeHolder(drawable);
    shapeHolder.setX(x);
    shapeHolder.setY(y);
    return shapeHolder;
}
 
private ShapeHolder createBall(float x, float y) {
	OvalShape circle = new OvalShape();
	circle.resize(BALL_SIZE, BALL_SIZE);
	ShapeDrawable drawable = new ShapeDrawable(circle);
	ShapeHolder shapeHolder = new ShapeHolder(drawable);
	shapeHolder.setX(x);
	shapeHolder.setY(y);
	return shapeHolder;
}
 
 同类方法