use of android.graphics.drawable.shapes.OvalShape in project FloatingActionButton by makovkastar.
the class FloatingActionButton method createDrawable.
private Drawable createDrawable(int color) {
OvalShape ovalShape = new OvalShape();
ShapeDrawable shapeDrawable = new ShapeDrawable(ovalShape);
shapeDrawable.getPaint().setColor(color);
if (mShadow && !hasLollipopApi()) {
Drawable shadowDrawable = getResources().getDrawable(mType == TYPE_NORMAL ? R.drawable.fab_shadow : R.drawable.fab_shadow_mini);
LayerDrawable layerDrawable = new LayerDrawable(new Drawable[] { shadowDrawable, shapeDrawable });
layerDrawable.setLayerInset(1, mShadowSize, mShadowSize, mShadowSize, mShadowSize);
return layerDrawable;
} else {
return shapeDrawable;
}
}
use of android.graphics.drawable.shapes.OvalShape in project Android-MaterialRefreshLayout by android-cjj.
the class CircleProgressBar method onLayout.
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
final float density = getContext().getResources().getDisplayMetrics().density;
mDiameter = Math.min(getMeasuredWidth(), getMeasuredHeight());
if (mDiameter <= 0) {
mDiameter = (int) density * DEFAULT_CIRCLE_DIAMETER;
}
if (getBackground() == null && mCircleBackgroundEnabled) {
final int shadowYOffset = (int) (density * Y_OFFSET);
final int shadowXOffset = (int) (density * X_OFFSET);
mShadowRadius = (int) (density * SHADOW_RADIUS);
if (elevationSupported()) {
mBgCircle = new ShapeDrawable(new OvalShape());
ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
} else {
OvalShape oval = new OvalShadow(mShadowRadius, mDiameter - mShadowRadius * 2);
mBgCircle = new ShapeDrawable(oval);
ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, mBgCircle.getPaint());
mBgCircle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR);
final int padding = (int) mShadowRadius;
// set padding so the inner image sits correctly within the shadow.
setPadding(padding, padding, padding, padding);
}
mBgCircle.getPaint().setColor(mBackGroundColor);
setBackgroundDrawable(mBgCircle);
}
mProgressDrawable.setBackgroundColor(mBackGroundColor);
mProgressDrawable.setColorSchemeColors(mColors);
mProgressDrawable.setSizeParameters(mDiameter, mDiameter, mInnerRadius <= 0 ? (mDiameter - mProgressStokeWidth * 2) / 4 : mInnerRadius, mProgressStokeWidth, mArrowWidth < 0 ? mProgressStokeWidth * 4 : mArrowWidth, mArrowHeight < 0 ? mProgressStokeWidth * 2 : mArrowHeight);
if (isShowArrow()) {
mProgressDrawable.showArrowOnFirstStart(true);
mProgressDrawable.setArrowScale(1f);
mProgressDrawable.showArrow(true);
}
super.setImageDrawable(null);
super.setImageDrawable(mProgressDrawable);
mProgressDrawable.setAlpha(255);
if (getVisibility() == VISIBLE) {
mProgressDrawable.setStartEndTrim(0, (float) 0.8);
}
}
use of android.graphics.drawable.shapes.OvalShape in project material-calendarview by prolificinteractive.
the class DayView method generateCircleDrawable.
private static Drawable generateCircleDrawable(final int color) {
ShapeDrawable drawable = new ShapeDrawable(new OvalShape());
drawable.getPaint().setColor(color);
return drawable;
}
use of android.graphics.drawable.shapes.OvalShape in project StylishMusicPlayer by ryanhoo.
the class AlbumImageView method init.
private void init() {
mDensity = getContext().getResources().getDisplayMetrics().density;
final int shadowXOffset = (int) (mDensity * X_OFFSET);
final int shadowYOffset = (int) (mDensity * Y_OFFSET);
mShadowRadius = (int) (mDensity * SHADOW_RADIUS);
ShapeDrawable circle;
if (elevationSupported()) {
circle = new ShapeDrawable(new OvalShape());
ViewCompat.setElevation(this, SHADOW_ELEVATION * mDensity);
} else {
OvalShape oval = new OvalShadow(mShadowRadius);
circle = new ShapeDrawable(oval);
ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, circle.getPaint());
circle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR);
final int padding = mShadowRadius;
// set padding so the inner image sits correctly within the shadow.
setPadding(padding, padding, padding, padding);
}
circle.getPaint().setAntiAlias(true);
circle.getPaint().setColor(DEFAULT_ALBUM_COLOR);
setBackground(circle);
mPaint.setAntiAlias(true);
mPaint.setTextAlign(Paint.Align.CENTER);
mPaint.setStyle(Paint.Style.FILL);
mPaint.setColor(DEFAULT_ALBUM_COLOR);
mPaint.setTextSize(ALBUM_CIRCLE_TEXT_SIZE * mDensity);
mRotateAnimator = ObjectAnimator.ofFloat(this, "rotation", 0f, 360f);
mRotateAnimator.setDuration(3600);
mRotateAnimator.setInterpolator(new LinearInterpolator());
mRotateAnimator.setRepeatMode(ValueAnimator.RESTART);
mRotateAnimator.setRepeatCount(ValueAnimator.INFINITE);
}
use of android.graphics.drawable.shapes.OvalShape in project StylishMusicPlayer by ryanhoo.
the class ShadowImageView method init.
private void init() {
final float density = getContext().getResources().getDisplayMetrics().density;
final int shadowXOffset = (int) (density * X_OFFSET);
final int shadowYOffset = (int) (density * Y_OFFSET);
mShadowRadius = (int) (density * SHADOW_RADIUS);
ShapeDrawable circle;
if (elevationSupported()) {
circle = new ShapeDrawable(new OvalShape());
ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
} else {
OvalShape oval = new OvalShadow(mShadowRadius);
circle = new ShapeDrawable(oval);
ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, circle.getPaint());
circle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR);
final int padding = mShadowRadius;
// set padding so the inner image sits correctly within the shadow.
setPadding(padding, padding, padding, padding);
}
circle.getPaint().setAntiAlias(true);
circle.getPaint().setColor(DEFAULT_BACKGROUND_COLOR);
setBackground(circle);
mRotateAnimator = ObjectAnimator.ofFloat(this, "rotation", 0f, 360f);
mRotateAnimator.setDuration(7200);
mRotateAnimator.setInterpolator(new LinearInterpolator());
mRotateAnimator.setRepeatMode(ValueAnimator.RESTART);
mRotateAnimator.setRepeatCount(ValueAnimator.INFINITE);
}
Aggregations