android.graphics.drawable.shapes.RectShape Java Examples
The following examples show how to use
android.graphics.drawable.shapes.RectShape.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DynamicPickerUtils.java From dynamic-support with Apache License 2.0 | 6 votes |
/** * Set a hue gradient progress drawable for a seek bar. * * @param seekBar The seek bar to set the hue gradient. */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static void setHueDrawable(@NonNull SeekBar seekBar) { if (DynamicSdkUtils.is21()) { seekBar.setProgressTintList(null); } LinearGradient gradient = new LinearGradient(0.0f, 0.0f, (float) seekBar.getWidth(), 0.0f, new int[] { 0xFFFF0000, 0xFFFFFF00, 0xFF00FF00, 0xFF00FFFF, 0xFF0000FF, 0xFFFF00FF, 0xFFFF0000 }, null, Shader.TileMode.CLAMP); ShapeDrawable shape = new ShapeDrawable(new RectShape()); shape.getPaint().setShader(gradient); Rect bounds = seekBar.getProgressDrawable().getBounds(); bounds.inset(0, (int) (bounds.height() * 0.45f)); seekBar.setProgressDrawable(shape); seekBar.getProgressDrawable().setBounds(bounds); }
Example #2
Source File: Ariana.java From Ariana with Apache License 2.0 | 6 votes |
public static Drawable drawable(final int[] colorBoxes, final float[] position, final GradientAngle gradientAngle) { ShapeDrawable.ShaderFactory shaderFactory = new ShapeDrawable.ShaderFactory() { @Override public Shader resize(int width, int height) { AngleCoordinate ac = AngleCoordinate.getAngleCoordinate(gradientAngle, width, height); LinearGradient linearGradient = new LinearGradient(ac.x1, ac.y1, ac.x2, ac.y2, colorBoxes, position, Shader.TileMode.REPEAT); return linearGradient; } }; PaintDrawable paint = new PaintDrawable(); paint.setShape(new RectShape()); paint.setShaderFactory(shaderFactory); return paint; }
Example #3
Source File: ProfileImageView.java From KlyphMessenger with MIT License | 6 votes |
public BorderDrawable(String shapeType, final int borderColor, final int borderWidth) { super(); final Shape shape = shapeType.equals(RECT) ? new RectShape() : new OvalShape(); final ShapeDrawable transparentShape = new ShapeDrawable(shape); transparentShape.getPaint().setColor(0x00000000);// Transparent final GradientDrawable shapeDrawable = new GradientDrawable(); shapeDrawable.setShape(shapeType.equals(RECT) ? GradientDrawable.RECTANGLE : GradientDrawable.OVAL); shapeDrawable.setStroke(borderWidth, borderColor); addState(new int[] { android.R.attr.state_enabled, android.R.attr.state_focused, -android.R.attr.state_pressed }, shapeDrawable); addState(new int[] { android.R.attr.state_enabled, -android.R.attr.state_focused, android.R.attr.state_pressed }, shapeDrawable); addState(new int[] { android.R.attr.state_enabled, android.R.attr.state_focused, android.R.attr.state_pressed }, shapeDrawable); addState(new int[] {}, transparentShape); }
Example #4
Source File: DefaultHeaderTransformer.java From KlyphMessenger with MIT License | 6 votes |
private void applyProgressBarSettings() { if (mHeaderProgressBar != null) { final int strokeWidth = mHeaderProgressBar.getResources() .getDimensionPixelSize(R.dimen.ptr_progress_bar_stroke_width); mHeaderProgressBar.setIndeterminateDrawable( new SmoothProgressDrawable.Builder(mHeaderProgressBar.getContext()) .color(mProgressDrawableColor) .width(strokeWidth) .build()); ShapeDrawable shape = new ShapeDrawable(); shape.setShape(new RectShape()); shape.getPaint().setColor(mProgressDrawableColor); ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL); mHeaderProgressBar.setProgressDrawable(clipDrawable); } }
Example #5
Source File: CropImageView.java From CropImageView with MIT License | 6 votes |
private Drawable getCropDrawable(int fillColor, int fillAlpha, int strokeColor, int strokeAlpha, int strokeWidth) { ShapeDrawable sd1 = new ShapeDrawable(new RectShape()); sd1.getPaint().setColor(strokeColor); sd1.getPaint().setStyle(Style.STROKE); sd1.getPaint().setStrokeWidth(strokeWidth); sd1.setAlpha(255); ShapeDrawable sd2 = new ShapeDrawable(new RectShape()); sd2.getPaint().setColor(fillColor); sd2.getPaint().setStyle(Style.FILL); sd2.setAlpha(fillAlpha); Drawable[] layers = new Drawable[2]; layers[0] = sd1; layers[1] = sd2; LayerDrawable composite = new LayerDrawable(layers); return composite; }
Example #6
Source File: ProfileImageView.java From Klyph with MIT License | 6 votes |
public BorderDrawable(String shapeType, final int borderColor, final int borderWidth) { super(); final Shape shape = shapeType.equals(RECT) ? new RectShape() : new OvalShape(); final ShapeDrawable transparentShape = new ShapeDrawable(shape); transparentShape.getPaint().setColor(0x00000000);// Transparent final GradientDrawable shapeDrawable = new GradientDrawable(); shapeDrawable.setShape(shapeType.equals(RECT) ? GradientDrawable.RECTANGLE : GradientDrawable.OVAL); shapeDrawable.setStroke(borderWidth, borderColor); addState(new int[] { android.R.attr.state_enabled, android.R.attr.state_focused, -android.R.attr.state_pressed }, shapeDrawable); addState(new int[] { android.R.attr.state_enabled, -android.R.attr.state_focused, android.R.attr.state_pressed }, shapeDrawable); addState(new int[] { android.R.attr.state_enabled, android.R.attr.state_focused, android.R.attr.state_pressed }, shapeDrawable); addState(new int[] {}, transparentShape); }
Example #7
Source File: DefaultHeaderTransformer.java From Klyph with MIT License | 6 votes |
private void applyProgressBarSettings() { if (mHeaderProgressBar != null) { final int strokeWidth = mHeaderProgressBar.getResources() .getDimensionPixelSize(R.dimen.ptr_progress_bar_stroke_width); mHeaderProgressBar.setIndeterminateDrawable( new SmoothProgressDrawable.Builder(mHeaderProgressBar.getContext()) .color(mProgressDrawableColor) .width(strokeWidth) .build()); ShapeDrawable shape = new ShapeDrawable(); shape.setShape(new RectShape()); shape.getPaint().setColor(mProgressDrawableColor); ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL); mHeaderProgressBar.setProgressDrawable(clipDrawable); } }
Example #8
Source File: ProfileImageView.java From Contacts with MIT License | 6 votes |
public BorderDrawable(String shapeType, final int borderColor, final int borderWidth) { super(); final Shape shape = shapeType.equals(RECT) ? new RectShape() : new OvalShape(); final ShapeDrawable transparentShape = new ShapeDrawable(shape); transparentShape.getPaint().setColor(0x00000000);// Transparent final GradientDrawable shapeDrawable = new GradientDrawable(); shapeDrawable.setShape(shapeType.equals(RECT) ? GradientDrawable.RECTANGLE : GradientDrawable.OVAL); shapeDrawable.setStroke(borderWidth, borderColor); addState(new int[] { android.R.attr.state_enabled, android.R.attr.state_focused, -android.R.attr.state_pressed }, shapeDrawable); addState(new int[] { android.R.attr.state_enabled, -android.R.attr.state_focused, android.R.attr.state_pressed }, shapeDrawable); addState(new int[] { android.R.attr.state_enabled, android.R.attr.state_focused, android.R.attr.state_pressed }, shapeDrawable); addState(new int[] {}, transparentShape); }
Example #9
Source File: TwitterStaticNativeAd.java From twitter-kit-android with Apache License 2.0 | 5 votes |
private void setCardStyling() { final boolean isLightBg = ColorUtils.isLightColor(containerBackgroundColor); if (isLightBg) { cardBorderColor = getResources().getColor(R.color.tw__ad_light_card_border_color); } else { cardBorderColor = getResources().getColor(R.color.tw__ad_dark_card_border_color); } final ShapeDrawable bgDrawable = new ShapeDrawable(new RectShape()); bgDrawable.getPaint().setColor(cardBackgroundColor); final ShapeDrawable borderDrawable = new ShapeDrawable(new RectShape()); borderDrawable.getPaint().setColor(cardBorderColor); final Drawable[] layers = new Drawable[2]; layers[0] = borderDrawable; layers[1] = bgDrawable; final LayerDrawable layerDrawable = new LayerDrawable(layers); layerDrawable.setLayerInset(0, 0, 0, 0, 0); layerDrawable.setLayerInset(1, 1, 0, 1, 0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { cardLayout.setBackground(layerDrawable); } else { cardLayout.setBackgroundDrawable(layerDrawable); } }
Example #10
Source File: PointScanManager.java From talkback with Apache License 2.0 | 5 votes |
/** * @param overlayController The overlay on which to show the scan bars * @param service The service that will dispatch the gestures */ public PointScanManager(OverlayController overlayController, AccessibilityService service) { this.overlayController = overlayController; this.service = service; lineDrawable = new ShapeDrawable(new RectShape()); isPerformingCustomSwipe = false; SwitchAccessPreferenceUtils.registerSwitchAccessPreferenceChangedListener(service, this); overlayController.addMenuListener(this); }
Example #11
Source File: CommentViewHolder.java From Hews with MIT License | 5 votes |
public Drawable getStripeDrawable() { ShapeDrawable bg = new ShapeDrawable(new RectShape()); int[] pixels = new int[indentWidth]; for (int i = 0; i < indentWidth / 3; i++) { pixels[i] = colorBg; pixels[i + indentWidth / 3] = colorBg; pixels[i + indentWidth / 3 * 2] = colorOrange; } Bitmap bm = Bitmap.createBitmap(pixels, indentWidth, 1, Bitmap.Config.ARGB_8888); Shader shader = new BitmapShader(bm, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT); bg.getPaint().setShader(shader); return bg; }
Example #12
Source File: OtherTaskFragment.java From Conquer with Apache License 2.0 | 5 votes |
private static ShapeDrawable createRectShape(int width, int height, int color) { ShapeDrawable shape = new ShapeDrawable(new RectShape()); shape.setIntrinsicHeight(height); shape.setIntrinsicWidth(width); shape.getPaint().setColor(color); return shape; }
Example #13
Source File: TextDrawable.java From NHentai-android with GNU General Public License v3.0 | 5 votes |
private Builder() { text = ""; color = Color.GRAY; textColor = Color.WHITE; borderThickness = 0; width = -1; height = -1; shape = new RectShape(); font = Typeface.create("sans-serif-light", Typeface.NORMAL); fontSize = -1; isBold = false; toUpperCase = false; }
Example #14
Source File: ThreadViewFragment.java From something.apk with MIT License | 5 votes |
private void updateHeaderState(){ ShapeDrawable shape = new ShapeDrawable(); shape.setShape(new RectShape()); shape.getPaint().setColor(page < maxPage ? nextPageColor : refreshColor); ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL); pfbProgressbar.setProgressDrawable(clipDrawable); pfbTitle.setText(page < maxPage ? R.string.pull_bottom_nextpage : R.string.pull_to_refresh_pull_label); }
Example #15
Source File: TextDrawable.java From TextDrawable with MIT License | 5 votes |
private Builder() { text = ""; color = Color.GRAY; textColor = Color.WHITE; borderThickness = 0; width = -1; height = -1; shape = new RectShape(); font = Typeface.create("sans-serif-light", Typeface.NORMAL); fontSize = -1; isBold = false; toUpperCase = false; }
Example #16
Source File: DefaultHeaderTransformer.java From Bitocle with Apache License 2.0 | 5 votes |
private void applyProgressBarSettings() { if (mHeaderProgressBar != null) { ShapeDrawable shape = new ShapeDrawable(); shape.setShape(new RectShape()); shape.getPaint().setColor(mProgressDrawableColor); ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL); mHeaderProgressBar.setProgressDrawable(clipDrawable); } }
Example #17
Source File: DefaultHeaderTransformer.java From Bitocle with Apache License 2.0 | 5 votes |
private void applyProgressBarSettings() { if (mHeaderProgressBar != null) { ShapeDrawable shape = new ShapeDrawable(); shape.setShape(new RectShape()); shape.getPaint().setColor(mProgressDrawableColor); ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL); mHeaderProgressBar.setProgressDrawable(clipDrawable); } }
Example #18
Source File: DefaultHeaderTransformer.java From Bitocle with Apache License 2.0 | 5 votes |
private void applyProgressBarSettings() { if (mHeaderProgressBar != null) { ShapeDrawable shape = new ShapeDrawable(); shape.setShape(new RectShape()); shape.getPaint().setColor(mProgressDrawableColor); ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL); mHeaderProgressBar.setProgressDrawable(clipDrawable); } }
Example #19
Source File: LiveButton.java From LiveButton with Apache License 2.0 | 5 votes |
private LayerDrawable getLayerList(boolean isPressed) { float[] radii = new float[8]; for (int i = 0; i < radii.length; i++) { radii[i] = corners; } ShapeDrawable shapeShadow = new ShapeDrawable(new RectShape()); shapeShadow.getPaint().setColor(shadowColor); shapeShadow.setShape(new RoundRectShape(radii, null, null)); ShapeDrawable shapeBackground = new ShapeDrawable(new RectShape()); shapeBackground.getPaint().setColor(backgroundColor); shapeBackground.setShape(new RoundRectShape(radii, null, null)); LayerDrawable composite = new LayerDrawable(new Drawable[]{shapeShadow, shapeBackground}); if (isPressed) { composite.setLayerInset(0, 0, (int) (normalHeight - pressedHeight), 0, 0); composite.setLayerInset(1, 0, (int) (normalHeight - pressedHeight), 0, (int) pressedHeight); } else { composite.setLayerInset(0, 0, 0, 0, 0); composite.setLayerInset(1, 0, 0, 0, (int) normalHeight); } return composite; }
Example #20
Source File: ProgressBarWrapper.java From Man-Man with GNU General Public License v3.0 | 5 votes |
private ProgressBar createProgressBar() { ProgressBar pb = (ProgressBar) View.inflate(mActivity, R.layout.actionbar_progressbar, null); ShapeDrawable shape = new ShapeDrawable(); shape.setShape(new RectShape()); shape.getPaint().setColor(Color.parseColor("#FF33B5E5")); ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL); pb.setProgressDrawable(clipDrawable); return pb; }
Example #21
Source File: TooltipErrorView.java From buddycloud-android with Apache License 2.0 | 5 votes |
/** * Get the tooltip shape * * @return */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) private Shape getTooltipShape() { Resources r = this.getContext().getResources(); final int pointHeightPx = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, POINTER_HEIGHT, r.getDisplayMetrics()); final int pointedHeightPx = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, POINTER_WIDE_HEIGHT, r.getDisplayMetrics()); final int pointStartPx = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, POINTER_START, r.getDisplayMetrics()); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mContentHolder .getLayoutParams(); mToolTipTV.setY(pointHeightPx); params.height = mToolTipTV.getHeight() + pointHeightPx; final Path rectPath = new Path(); final Path rectBorderPath = new Path(); // Create the rectangular shape Shape shape = new RectShape() { @Override protected void onResize(float w, float h) { createShapePath(rectPath, rectBorderPath, w, h, pointHeightPx, pointedHeightPx, pointStartPx); } @Override public void draw(Canvas canvas, Paint paint) { drawOnCanvas(canvas, paint, rectPath, rectBorderPath); } }; return shape; }
Example #22
Source File: OrreryDrawable.java From AnimationApiDemos with Apache License 2.0 | 5 votes |
public static OrreryDrawable Create() { ShapeDrawable space = new ShapeDrawable(new RectShape()); space.getPaint().setColor(Color.BLACK); space.setIntrinsicHeight(SPACE_HEIGHT); space.setIntrinsicWidth(SPACE_HEIGHT); ShapeDrawable sun = new ShapeDrawable(new OvalShape()); sun.getPaint().setColor(Color.YELLOW); sun.setIntrinsicHeight(RADIUS_SUN * 2); sun.setIntrinsicWidth(RADIUS_SUN * 2); ShapeDrawable earth = new ShapeDrawable(new OvalShape()); earth.getPaint().setColor(Color.BLUE); earth.setIntrinsicHeight(RADIUS_EARTH * 2); earth.setIntrinsicWidth(RADIUS_EARTH * 2); ShapeDrawable moon = new ShapeDrawable(new OvalShape()); moon.getPaint().setColor(Color.LTGRAY); moon.setIntrinsicHeight(RADIUS_MOON * 2); moon.setIntrinsicWidth(RADIUS_MOON * 2); Drawable[] bodies = { space, sun, earth, moon }; OrreryDrawable myOrrery = new OrreryDrawable(bodies); myOrrery.setEarthPosition(0); myOrrery.setMoonPosition(0); myOrrery.setLayerInset(SPACE_ID, 0, 0, 0, 0); myOrrery.setLayerInset(SUN_ID, SPACE_HEIGHT / 2 - RADIUS_SUN, SPACE_HEIGHT / 2 - RADIUS_SUN, SPACE_HEIGHT / 2 - RADIUS_SUN, SPACE_HEIGHT / 2 - RADIUS_SUN); return myOrrery; }
Example #23
Source File: TextDrawable.java From ImageLetterIcon with Apache License 2.0 | 5 votes |
private Builder() { text = ""; color = Color.GRAY; borderColor = getDarkerShade(color); textColor = Color.WHITE; borderThickness = 0; width = -1; height = -1; shape = new RectShape(); font = Typeface.DEFAULT; fontSize = -1; isBold = false; toUpperCase = false; }
Example #24
Source File: TextDrawable.java From XERUNG with Apache License 2.0 | 5 votes |
private Builder() { text = ""; color = Color.GRAY; textColor = Color.WHITE; borderThickness = 0; width = -1; height = -1; shape = new RectShape(); font = Typeface.create("sans-serif-light", Typeface.NORMAL); fontSize = -1; isBold = false; toUpperCase = false; }
Example #25
Source File: TextDrawable.java From XERUNG with Apache License 2.0 | 5 votes |
private Builder() { text = ""; color = Color.GRAY; textColor = Color.WHITE; borderThickness = 0; width = -1; height = -1; shape = new RectShape(); font = Typeface.create("sans-serif-light", Typeface.NORMAL); fontSize = -1; isBold = false; toUpperCase = false; }
Example #26
Source File: SimpleRecyclerView.java From SimpleRecyclerView with Apache License 2.0 | 5 votes |
private void addDividerItemDecoration(@ColorInt int color, int orientation, int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) { DividerItemDecoration decor = new DividerItemDecoration(getContext(), orientation); if (color != 0) { ShapeDrawable shapeDrawable = new ShapeDrawable(new RectShape()); shapeDrawable.setIntrinsicHeight(Utils.dpToPx(getContext(), 1)); shapeDrawable.setIntrinsicWidth(Utils.dpToPx(getContext(), 1)); shapeDrawable.getPaint().setColor(color); InsetDrawable insetDrawable = new InsetDrawable(shapeDrawable, paddingLeft, paddingTop, paddingRight, paddingBottom); decor.setDrawable(insetDrawable); } decor.setShowLastDivider(showLastDivider); addItemDecoration(decor); }
Example #27
Source File: ButtonBase.java From appinventor-extensions with Apache License 2.0 | 5 votes |
private void setShape() { ShapeDrawable drawable = new ShapeDrawable(); // Set shape of drawable. switch (shape) { case Component.BUTTON_SHAPE_ROUNDED: drawable.setShape(new RoundRectShape(ROUNDED_CORNERS_ARRAY, null, null)); break; case Component.BUTTON_SHAPE_RECT: drawable.setShape(new RectShape()); break; case Component.BUTTON_SHAPE_OVAL: drawable.setShape(new OvalShape()); break; default: throw new IllegalArgumentException(); } // Set drawable to the background of the button. if (!AppInventorCompatActivity.isClassicMode() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ViewUtil.setBackgroundDrawable(view, new RippleDrawable(createRippleState(), drawable, drawable)); } else { ViewUtil.setBackgroundDrawable(view, drawable); } if (backgroundColor == Component.COLOR_NONE) { view.getBackground().setColorFilter(backgroundColor, PorterDuff.Mode.CLEAR); } else if (backgroundColor == Component.COLOR_DEFAULT) { view.getBackground().setColorFilter(SHAPED_DEFAULT_BACKGROUND_COLOR, PorterDuff.Mode.SRC_ATOP); } else { view.getBackground().setColorFilter(backgroundColor, PorterDuff.Mode.SRC_ATOP); } view.invalidate(); }
Example #28
Source File: TextDrawable.java From Muzesto with GNU General Public License v3.0 | 5 votes |
private Builder() { text = ""; color = Color.GRAY; textColor = Color.WHITE; borderThickness = 0; width = -1; height = -1; shape = new RectShape(); font = Typeface.create("sans-serif-light", Typeface.NORMAL); fontSize = -1; isBold = false; toUpperCase = false; }
Example #29
Source File: DefaultHeaderTransformer.java From AndroidPullMenu with Apache License 2.0 | 5 votes |
private void applyProgressBarSettings() { if (mHeaderProgressBar != null) { ShapeDrawable shape = new ShapeDrawable(); shape.setShape(new RectShape()); shape.getPaint().setColor(mProgressDrawableColor); ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL); mHeaderProgressBar.setProgressDrawable(clipDrawable); } }
Example #30
Source File: TextDrawable.java From CanPhotos with Apache License 2.0 | 5 votes |
private Builder() { text = ""; color = Color.GRAY; textColor = Color.WHITE; borderThickness = 0; width = -1; height = -1; shape = new RectShape(); font = Typeface.create("sans-serif-light", Typeface.NORMAL); fontSize = -1; isBold = false; toUpperCase = false; }