List of usage examples for android.graphics.drawable ShapeDrawable getPaint
public Paint getPaint()
From source file:com.qingxu.android.huhudaily.view.CircleImageView.java
public CircleImageView(Context context, int color, final float radius) { super(context); 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); ShapeDrawable circle; if (elevationSupported()) { circle = new ShapeDrawable(new OvalShape()); ViewCompat.setElevation(this, SHADOW_ELEVATION * density); } else {//from ww w. j a v a2 s . co m OvalShape oval = new CircleImageView.OvalShadow(mShadowRadius, diameter); 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().setColor(color); setBackgroundDrawable(circle); }
From source file:ru.gkpromtech.exhibition.utils.CircleImageView.java
private void sharedConstructor(int color, final float radius) { 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); ShapeDrawable circle; if (elevationSupported()) { circle = new ShapeDrawable(new OvalShape()); ViewCompat.setElevation(this, SHADOW_ELEVATION * density); } else {/*ww w . j a v a2 s. c o m*/ OvalShape oval = new OvalShadow(mShadowRadius, diameter); 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 = (int) mShadowRadius; // set padding so the inner image sits correctly within the shadow. setPadding(padding, padding, padding, padding); } circle.getPaint().setColor(color); setBackground(circle); }
From source file:com.banxi1988.v2exgeek.view.CircleImageView.java
private void initImageview(int color, final float radius) { 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); ShapeDrawable circle; if (elevationSupported()) { circle = new ShapeDrawable(new OvalShape()); ViewCompat.setElevation(this, SHADOW_ELEVATION * density); } else {//from www. j a va 2 s. co m OvalShape oval = new OvalShadow(mShadowRadius, diameter); 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().setColor(color); setBackgroundDrawable(circle); }
From source file:com.cylan.jiafeigou.widget.JFGCircleImageView.java
public JFGCircleImageView(Context context, int color, final float radius) { super(context); 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); ShapeDrawable circle; if (elevationSupported()) { circle = new ShapeDrawable(new OvalShape()); ViewCompat.setElevation(this, SHADOW_ELEVATION * density); } else {//from w w w . j av a 2s . com OvalShape oval = new JFGCircleImageView.OvalShadow(mShadowRadius, diameter); 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().setColor(color); setBackgroundDrawable(circle); }
From source file:com.androidhuman.circlerefreshlayout.CircleImageView.java
public CircleImageView(Context context, int color, final float radius) { super(context); 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); ShapeDrawable circle; if (elevationSupported()) { circle = new ShapeDrawable(new OvalShape()); ViewCompat.setElevation(this, SHADOW_ELEVATION * density); } else {/*from w ww . j a va 2s .c o m*/ OvalShape oval = new OvalShadow(mShadowRadius, diameter); 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().setColor(color); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { //noinspection deprecation setBackgroundDrawable(circle); } else { setBackground(circle); } }
From source file:com.wudoumi.battertest.view.CircleImageView.java
private void init(int color, final float radius) { 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); ShapeDrawable circle; if (elevationSupported()) { circle = new ShapeDrawable(new OvalShape()); ViewCompat.setElevation(this, SHADOW_ELEVATION * density); } else {/*from ww w. j ava 2 s .c o m*/ OvalShape oval = new OvalShadow(mShadowRadius, diameter); 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().setColor(color); setBackgroundDrawable(circle); }
From source file:com.richtodd.android.quiltdesign.block.PaperPiecedBlockPiece.java
private Drawable createDrawable(RenderOptions renderOptions) { PathShape pathShape = new PathShape(getPath(renderOptions.getWidth(), renderOptions.getHeight()), renderOptions.getWidth(), renderOptions.getHeight()); if (renderOptions.getRenderStyle() == RenderStyles.BlackWhite) { ShapeDrawable strokeDrawable = new ShapeDrawable(pathShape); strokeDrawable.setBounds(0, 0, renderOptions.getWidth(), renderOptions.getHeight()); strokeDrawable.getPaint().setColor(Color.BLACK); strokeDrawable.getPaint().setStyle(Paint.Style.STROKE); strokeDrawable.getPaint().setStrokeWidth(renderOptions.getStrokeWidth()); ShapeDrawable fillDrawable = new ShapeDrawable(pathShape); fillDrawable.setBounds(0, 0, renderOptions.getWidth(), renderOptions.getHeight()); fillDrawable.getPaint().setColor(Color.WHITE); fillDrawable.getPaint().setStyle(Paint.Style.FILL); Drawable[] layers = new Drawable[2]; layers[0] = fillDrawable;//from w w w . j av a2s . c o m layers[1] = strokeDrawable; LayerDrawable drawable = new LayerDrawable(layers); return drawable; } else { ShapeDrawable drawable = new ShapeDrawable(pathShape); drawable.getPaint().setColor(getColor()); drawable.getPaint().setStyle(Paint.Style.FILL); return drawable; } }
From source file:com.zzmstring.viewset.View.LoadingProgressBar.CircleProgressBar.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 w w. ja va 2 s.c o m*/ if (getBackground() == null) { final int shadowYOffset = (int) (density * Y_OFFSET); final int shadowXOffset = (int) (density * X_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, mDiameter); 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 = (int) mShadowRadius; // set padding so the inner image sits correctly within the shadow. setPadding(padding, padding, padding, padding); } circle.getPaint().setColor(mBackGroundColor); setBackgroundDrawable(circle); } if (getDrawable() == null) { MaterialProgressDrawable progressDrawable = new MaterialProgressDrawable(getContext(), this); progressDrawable.setBackgroundColor(mBackGroundColor); progressDrawable.setArrowScale(1f); // progressDrawable.showArrow(true); // progressDrawable.setStartEndTrim(0, 180); progressDrawable.setSizeParameters(mDiameter, mDiameter, mInnerRadius <= 0 ? (mDiameter - mProgressStokeWidth * 2) / 4 : mInnerRadius, mProgressStokeWidth, mArrowWidth < 0 ? mProgressStokeWidth * 4 : mArrowWidth, mArrowHeight < 0 ? mProgressStokeWidth * 2 : mArrowHeight); super.setImageDrawable(progressDrawable); progressDrawable.setAlpha(150); progressDrawable.start(); } }
From source file:ticwear.design.widget.FloatingActionButton.java
Drawable createShapeDrawable() { ShapeDrawable d = new ShapeDrawable(); d.setShape(new OvalShape()); d.getPaint().setColor(Color.WHITE); return d;/*from ww w. java 2s . c om*/ }
From source file:gov.sfmta.sfpark.MainScreenActivity.java
public boolean displayData(boolean progress) { if (SFparkActivity.responseString == null || SFparkActivity.responseString == "") { return false; }//from w w w. j a v a 2s .com // ISO8601 date SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'H:mm:ss'.'SSSZZZZ"); try { timeStamp = df.parse(timeStampXML); } catch (ParseException e) { e.printStackTrace(); } SimpleDateFormat formatter = new SimpleDateFormat("h:mma"); String now = formatter.format(timeStamp); if (showPrice) { legendImage.setImageResource(R.drawable.key_pricing); legendlabel.setText("Price as of " + now); } else { legendImage.setImageResource(R.drawable.key_availability); legendlabel.setText("Availability as of " + now); } //convert time stamp to minutes. String now is 24 hour time display. SimpleDateFormat formatter24 = new SimpleDateFormat("HH:mm"); String now24 = formatter24.format(timeStamp); String[] time2 = now24.split(":"); int hours = Integer.valueOf(time2[0]); int minutes = Integer.valueOf(time2[1]); // for price bucket calculations timeStampMinutes = (hours * 60) + minutes; if ((showPrice == true) && (pricingAnnotationsOverlay != null)) { updateMap(); return true; } if ((showPrice == false) && (availabilityAnnotationsOverlay != null)) { updateMap(); return true; } ShapeDrawable invisible = new ShapeDrawable(new RectShape()); invisible.getPaint().setColor(0x00000000); if (showPrice == true) { pricingAnnotationsOverlay = new AnnotationsOverlay(invisible, mapView.getContext()); pricingAnnotationsOverlay.loadOverlaysProgress(showPrice); } else { // NPE!! availabilityAnnotationsOverlay = new AnnotationsOverlay(invisible, mapView.getContext()); availabilityAnnotationsOverlay.loadOverlays(showPrice); updateMap(); } return true; }