use of android.graphics.drawable.shapes.OvalShape in project actor-platform by actorapp.
the class ShareMenuButtonFactory method get.
public static StateListDrawable get(int color, Context context) {
ShapeDrawable bg = new ShapeDrawable(new OvalShape());
int padding = Screen.dp(5);
bg.getPaint().setColor(color);
ShapeDrawable bgPressed = new ShapeDrawable(new OvalShape());
bgPressed.getPaint().setColor(ActorStyle.getDarkenArgb(color, 0.95));
StateListDrawable states = new StateListDrawable();
states.addState(new int[] { android.R.attr.state_pressed }, new InsetDrawable(bgPressed, padding));
states.addState(StateSet.WILD_CARD, new InsetDrawable(bg, padding));
return states;
}
use of android.graphics.drawable.shapes.OvalShape in project ImageWindow by kanytu.
the class ImageWindow method init.
private void init() {
ImageView closeButton = new ImageView(getContext());
closeButton.setLayoutParams(new RelativeLayout.LayoutParams((int) (mCloseButtonSize), (int) (mCloseButtonSize)));
StateListDrawable drawable = new StateListDrawable();
ShapeDrawable shape = new ShapeDrawable(new OvalShape());
ShapeDrawable shapePressed = new ShapeDrawable(new OvalShape());
shape.setColorFilter(mCloseColor, PorterDuff.Mode.SRC_ATOP);
//a little bit darker
shapePressed.setColorFilter(mCloseColor - 0x444444, PorterDuff.Mode.SRC_ATOP);
drawable.addState(new int[] { android.R.attr.state_pressed }, shapePressed);
drawable.addState(new int[] {}, shape);
closeButton.setImageResource(mCloseIcon);
//todo change this to support lower api
closeButton.setBackground(drawable);
closeButton.setClickable(true);
closeButton.setId(R.id.closeId);
mImageView = new CustomImageView(getContext(), mCloseButtonSize, mCloseButtonMargin, mCornerRadius);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMargins(Math.round(mTopLeftMargin), Math.round(mTopLeftMargin), 0, 0);
mImageView.setLayoutParams(params);
mImageView.setAdjustViewBounds(true);
addView(mImageView);
addView(closeButton);
}
use of android.graphics.drawable.shapes.OvalShape in project FlyRefresh by race604.
the class PullHeaderLayout method setActionDrawable.
public void setActionDrawable(Drawable actionDrawable) {
mActionDrawable = actionDrawable;
if (mActionDrawable != null) {
if (mActionView == null) {
final int bgColor = UIUtils.getThemeColorFromAttrOrRes(getContext(), R.attr.colorAccent, R.color.accent);
final int pressedColor = UIUtils.darkerColor(bgColor, 0.8f);
final ShapeDrawable bgDrawable = new ShapeDrawable(new OvalShape());
bgDrawable.getPaint().setColor(bgColor);
mActionView = new FloatingActionButton(getContext());
mActionView.setRippleColor(pressedColor);
mActionView.setBackgroundDrawable(bgDrawable);
addView(mActionView, new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
if (mFlyView == null) {
mFlyView = new ImageView(getContext());
mFlyView.setScaleType(ImageView.ScaleType.FIT_XY);
addView(mFlyView, new LayoutParams(ACTION_ICON_SIZE, ACTION_ICON_SIZE));
mFlyView.bringToFront();
float elevation = ViewCompat.getElevation(mActionView);
ViewCompat.setElevation(mFlyView, elevation + 1);
}
mFlyView.setImageDrawable(mActionDrawable);
} else {
if (mActionView != null) {
removeView(mActionView);
removeView(mFlyView);
mActionView = null;
mFlyView = null;
}
}
}
use of android.graphics.drawable.shapes.OvalShape in project BottomBar by roughike.
the class BadgeCircle method make.
/**
* Creates a new circle for the Badge background.
*
* @param size the width and height for the circle
* @param color the activeIconColor for the circle
* @return a nice and adorable circle.
*/
static ShapeDrawable make(int size, int color) {
ShapeDrawable indicator = new ShapeDrawable(new OvalShape());
indicator.setIntrinsicWidth(size);
indicator.setIntrinsicHeight(size);
indicator.getPaint().setColor(color);
return indicator;
}
use of android.graphics.drawable.shapes.OvalShape in project android-Ultra-Pull-To-Refresh by liaohuqiu.
the class MaterialProgressDrawable method setUp.
private void setUp(final double diameter) {
PtrLocalDisplay.init(mParent.getContext());
final int shadowYOffset = PtrLocalDisplay.dp2px(Y_OFFSET);
final int shadowXOffset = PtrLocalDisplay.dp2px(X_OFFSET);
int mShadowRadius = PtrLocalDisplay.dp2px(SHADOW_RADIUS);
OvalShape oval = new OvalShadow(mShadowRadius, (int) diameter);
mShadow = new ShapeDrawable(oval);
if (Build.VERSION.SDK_INT >= 11) {
mParent.setLayerType(View.LAYER_TYPE_SOFTWARE, mShadow.getPaint());
}
mShadow.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR);
}
Aggregations