List of usage examples for android.graphics.drawable ShapeDrawable ShapeDrawable
public ShapeDrawable(Shape s)
From source file:com.gj.administrator.gjerp.view.CircleIndicator.java
private void createTabItems() { for (int i = 0; i < viewPager.getAdapter().getCount(); i++) { OvalShape circle = new OvalShape(); ShapeDrawable drawable = new ShapeDrawable(circle); ShapeHolder shapeHolder = new ShapeHolder(drawable); Paint paint = drawable.getPaint(); paint.setColor(mIndicatorBackground); paint.setAntiAlias(true);/*from w w w. j av a 2s .c om*/ shapeHolder.setPaint(paint); tabItems.add(shapeHolder); } }
From source file:com.github.hilo.widget.MaterialCircleProgressBar.java
@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; }//from w ww .j av a 2 s .c o m 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 OvalShadow(1, 0)); 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 = mShadowRadius; // set padding so the inner image sits correctly within the shadow. setPadding(padding, padding, padding, padding); } // TODO: mBgCircle.getPaint().setColor(mCircleBackGroundColor; mBgCircle.getPaint().setColor(getResources().getColor(R.color.cpb_white)); setBackgroundDrawable(mBgCircle); } mProgressDrawable.setBackgroundColor(mCircleBackGroundColor); mProgressDrawable.setColorSchemeColors(mColors); mProgressDrawable.setSizeParameters(mDiameter, mDiameter, mInnerRadius <= 0 ? (mDiameter - mArrowStokeWidth * 2) / 4 : mInnerRadius, mArrowStokeWidth, mArrowWidth < 0 ? mArrowStokeWidth * 4 : mArrowWidth, mArrowHeight < 0 ? mArrowStokeWidth * 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); } }
From source file:com.gudong.appkit.ui.fragment.ColorChooseDialog.java
private Drawable createSelector(int color) { ShapeDrawable coloredCircle = new ShapeDrawable(new OvalShape()); coloredCircle.getPaint().setColor(color); ShapeDrawable darkerCircle = new ShapeDrawable(new OvalShape()); darkerCircle.getPaint().setColor(shiftColor(color)); StateListDrawable stateListDrawable = new StateListDrawable(); stateListDrawable.addState(new int[] { -android.R.attr.state_pressed }, coloredCircle); stateListDrawable.addState(new int[] { android.R.attr.state_pressed }, darkerCircle); return stateListDrawable; }
From source file:com.gj.administrator.gjerp.view.CircleIndicator.java
private void createMovingItem() { OvalShape circle = new OvalShape(); ShapeDrawable drawable = new ShapeDrawable(circle); movingItem = new ShapeHolder(drawable); Paint paint = drawable.getPaint(); paint.setColor(mIndicatorSelectedBackground); paint.setAntiAlias(true);/*from w ww. j a v a 2 s . c o m*/ switch (mIndicatorMode) { case INSIDE: paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP)); break; case OUTSIDE: paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER)); break; case SOLO: paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC)); break; } movingItem.setPaint(paint); }
From source file:com.mopaas_mobile.pulltorefresh.header.MaterialProgressDrawable.java
private void setUp(final double diameter) { 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()); }/*from w w w .ja va 2 s . com*/ mShadow.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR); }
From source file:cn.jiguang.imui.messages.MaterialProgressDrawable.java
private void setUp(final double diameter) { final int shadowYOffset = DisplayUtil.dp2px(mParent.getContext(), Y_OFFSET); final int shadowXOffset = DisplayUtil.dp2px(mParent.getContext(), X_OFFSET); int mShadowRadius = DisplayUtil.dp2px(mParent.getContext(), SHADOW_RADIUS); OvalShape oval = new OvalShadow(mShadowRadius, (int) diameter); mShadow = new ShapeDrawable(oval); mParent.setLayerType(View.LAYER_TYPE_SOFTWARE, mShadow.getPaint()); mShadow.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR); }
From source file:com.uaeemployee.Utils.MaterialProgressBar.java
@SuppressLint("DrawAllocation") @Override//from w w w.j a v a 2 s. co m 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); 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.setArrowScale(1f); mProgressDrawable.showArrow(true); } super.setImageDrawable(null); super.setImageDrawable(mProgressDrawable); mProgressDrawable.setAlpha(255); mProgressDrawable.start(); }
From source file:cn.finalteam.loadingviewfinal.header.MaterialProgressDrawable.java
@SuppressLint("NewApi") private void setUp(final double diameter) { 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()); }//from w ww. jav a 2s . c o m mShadow.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR); }
From source file:com.yan.refreshloadlayouttest.widget.MaterialProgressDrawable.java
private void setUp(final double diameter) { final int shadowYOffset = dipToPx(mParent.getContext(), Y_OFFSET); final int shadowXOffset = dipToPx(mParent.getContext(), X_OFFSET); int mShadowRadius = dipToPx(mParent.getContext(), 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()); }// ww w .java 2 s .c o m mShadow.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR); }
From source file:com.eventer.app.view.CircleProgressBar.java
@SuppressWarnings("deprecation") @Override//from w w w. j a v a 2s . c o m 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.start(); } }