use of android.graphics.drawable.shapes.OvalShape in project android-PullRefreshLayout by baoyongzhang.
the class MaterialDrawable method createCircleDrawable.
private void createCircleDrawable() {
float radius = CIRCLE_DIAMETER / 2;
final float density = getContext().getResources().getDisplayMetrics().density;
final int diameter = (int) (radius * density * 2);
final int shadowYOffset = (int) (density * Y_OFFSET);
final int shadowXOffset = (int) (density * X_OFFSET);
mShadowRadius = (int) (density * SHADOW_RADIUS);
OvalShape oval = new OvalShadow(mShadowRadius, diameter);
mCircle = new ShapeDrawable(oval);
// ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, circle.getPaint());
mCircle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR);
mPadding = (int) mShadowRadius;
mCircle.getPaint().setColor(Color.WHITE);
}
use of android.graphics.drawable.shapes.OvalShape in project Space-Navigation-View by armcha.
the class BadgeHelper method makeShapeDrawable.
/**
* Make circle drawable for badge background
*
* @param color background color
* @return return colored circle drawable
*/
static ShapeDrawable makeShapeDrawable(int color) {
ShapeDrawable badgeBackground = new ShapeDrawable(new OvalShape());
badgeBackground.setIntrinsicWidth(10);
badgeBackground.setIntrinsicHeight(10);
badgeBackground.getPaint().setColor(color);
return badgeBackground;
}
use of android.graphics.drawable.shapes.OvalShape in project coursera-android by aporter.
the class ShapeDrawActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
int width = (int) getResources().getDimension(R.dimen.image_width);
int height = (int) getResources().getDimension(R.dimen.image_height);
int padding = (int) getResources().getDimension(R.dimen.padding);
// Get container View
RelativeLayout rl = (RelativeLayout) findViewById(R.id.main_window);
// Create Cyan Shape
ShapeDrawable cyanShape = new ShapeDrawable(new OvalShape());
cyanShape.getPaint().setColor(Color.CYAN);
cyanShape.setIntrinsicHeight(height);
cyanShape.setIntrinsicWidth(width);
cyanShape.setAlpha(alpha);
// Put Cyan Shape into an ImageView
ImageView cyanView = new ImageView(getApplicationContext());
cyanView.setImageDrawable(cyanShape);
cyanView.setPadding(padding, padding, padding, padding);
// Specify placement of ImageView within RelativeLayout
RelativeLayout.LayoutParams cyanViewLayoutParams = new RelativeLayout.LayoutParams(height, width);
cyanViewLayoutParams.addRule(RelativeLayout.CENTER_VERTICAL);
cyanViewLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
cyanView.setLayoutParams(cyanViewLayoutParams);
rl.addView(cyanView);
// Create Magenta Shape
ShapeDrawable magentaShape = new ShapeDrawable(new OvalShape());
magentaShape.getPaint().setColor(Color.MAGENTA);
magentaShape.setIntrinsicHeight(height);
magentaShape.setIntrinsicWidth(width);
magentaShape.setAlpha(alpha);
// Put Magenta Shape into an ImageView
ImageView magentaView = new ImageView(getApplicationContext());
magentaView.setImageDrawable(magentaShape);
magentaView.setPadding(padding, padding, padding, padding);
// Specify placement of ImageView within RelativeLayout
RelativeLayout.LayoutParams magentaViewLayoutParams = new RelativeLayout.LayoutParams(height, width);
magentaViewLayoutParams.addRule(RelativeLayout.CENTER_VERTICAL);
magentaViewLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
magentaView.setLayoutParams(magentaViewLayoutParams);
rl.addView(magentaView);
}
use of android.graphics.drawable.shapes.OvalShape in project android-floating-action-button by futuresimple.
the class FloatingActionButton method createOuterStrokeDrawable.
private Drawable createOuterStrokeDrawable(float strokeWidth) {
ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());
final Paint paint = shapeDrawable.getPaint();
paint.setAntiAlias(true);
paint.setStrokeWidth(strokeWidth);
paint.setStyle(Style.STROKE);
paint.setColor(Color.BLACK);
paint.setAlpha(opacityToAlpha(0.02f));
return shapeDrawable;
}
use of android.graphics.drawable.shapes.OvalShape in project android-floating-action-button by futuresimple.
the class FloatingActionButton method createCircleDrawable.
private Drawable createCircleDrawable(int color, float strokeWidth) {
int alpha = Color.alpha(color);
int opaqueColor = opaque(color);
ShapeDrawable fillDrawable = new ShapeDrawable(new OvalShape());
final Paint paint = fillDrawable.getPaint();
paint.setAntiAlias(true);
paint.setColor(opaqueColor);
Drawable[] layers = { fillDrawable, createInnerStrokesDrawable(opaqueColor, strokeWidth) };
LayerDrawable drawable = alpha == 255 || !mStrokeVisible ? new LayerDrawable(layers) : new TranslucentLayerDrawable(alpha, layers);
int halfStrokeWidth = (int) (strokeWidth / 2f);
drawable.setLayerInset(1, halfStrokeWidth, halfStrokeWidth, halfStrokeWidth, halfStrokeWidth);
return drawable;
}
Aggregations