Java Code Examples for android.graphics.drawable.shapes.OvalShape#resize()
The following examples show how to use
android.graphics.drawable.shapes.OvalShape#resize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicAnimationActivity.java From AnimationApiDemos with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: DownloadNotificationService.java From AndroidChromium with Apache License 2.0 | 6 votes |
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; }
Example 3
Source File: DownloadNotificationService.java From 365browser with Apache License 2.0 | 6 votes |
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; }
Example 4
Source File: MultiPropertyAnimation.java From AnimationApiDemos with Apache License 2.0 | 6 votes |
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; }
Example 5
Source File: CustomEvaluator.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
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; }
Example 6
Source File: AnimationCloning.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
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; }
Example 7
Source File: BouncingBalls.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
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; }
Example 8
Source File: BouncingBalls.java From AnimationApiDemos with Apache License 2.0 | 6 votes |
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; }
Example 9
Source File: AnimationSeeking.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
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; }
Example 10
Source File: ReversingAnimation.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
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; }
Example 11
Source File: MultiPropertyAnimation.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
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; }
Example 12
Source File: AnimatorEvents.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
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; }
Example 13
Source File: CustomEvaluator.java From AnimationApiDemos with Apache License 2.0 | 6 votes |
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; }
Example 14
Source File: AnimationLoading.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
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; }
Example 15
Source File: AnimationFromXmlActivity.java From AnimationApiDemos with Apache License 2.0 | 5 votes |
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; }
Example 16
Source File: MonthView.java From Memory-capsule with Apache License 2.0 | 5 votes |
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; }
Example 17
Source File: MonthView.java From DatePicker with Apache License 2.0 | 5 votes |
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; }
Example 18
Source File: MonthView.java From nono-android with GNU General Public License v3.0 | 5 votes |
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; }
Example 19
Source File: MonthView.java From SignCalender with Apache License 2.0 | 5 votes |
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; }