Android GradientDrawable - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android GradientDrawable class.

This code example shows how to use the following methods: setCornerRadius, setGradientRadius, setShape
		mDrawSelected = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
		        new int[] { 0x77FFFFFF, selectedColor,selectedColor,selectedColor,selectedColor, 0x77000000 });
		mDrawSelected.setShape(GradientDrawable.RECTANGLE);
		mDrawSelected.setGradientRadius((float)(Math.sqrt(2) * 60));
		mDrawSelected.setCornerRadius(8);
		mDrawPressed = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
				new int[] { 0x77FFFFFF, pressedColor,pressedColor,pressedColor,pressedColor, 0x77000000 });
		mDrawPressed.setShape(GradientDrawable.RECTANGLE);
		mDrawPressed.setGradientRadius((float)(Math.sqrt(2) * 60));
		mDrawPressed.setCornerRadius(8);
 
		drawable.addState(new int[]{ statePressed}, mDrawPressed);
		drawable.addState(new int[]{ stateFocused, stateWindowFocused}, mDrawSelected);
		drawable.addState(new int[]{stateFocused, -stateWindowFocused}, null);
		drawable.addState(new int[]{-stateFocused, stateWindowFocused}, null);
		drawable.addState(new int[]{-stateFocused, -stateWindowFocused}, null);
		return drawable;
	} 
	private static Drawable oldSelector(Context context, int type){
		int selectedColor=AlmostNexusSettingsHelper.getHighlightsColorFocus(context);
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setBounds, setLevel, draw, setDither
			int col = Color.HSVToColor(hsv);
 
			int colors[] = new int[2];
			colors[0] = col;
			colors[1] = 0xFF000000;
			GradientDrawable gradDraw = new GradientDrawable(Orientation.TOP_BOTTOM, colors);
			gradDraw.setDither(true);
			gradDraw.setLevel(10000);
			gradDraw.setBounds(0, 0, SLIDER_THICKNESS, PALETTE_DIM);
			gradDraw.draw(mVerSliderCv);
		} 
 
		/** 
		 * Report the correct tightly bounded dimensions of the view. 
		 */ 
		@Override 
		protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
			setMeasuredDimension(VIEW_DIM_X, VIEW_DIM_Y);
		} 
 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setStroke
	} 
	private GradientDrawable makeGradientDrawable(Orientation orientation, 
			int startColor, int centerColor, int endColor, float strokeDips, int strokeColor)
	{ 
		GradientDrawable gd = makeGradientDrawable(orientation, startColor, centerColor, endColor);
		gd.setStroke(dipToInt(strokeDips), strokeColor);
		return gd;
	} 
	 
	private GradientDrawable makeGradientDrawable(Orientation orientation, 
			int startColor, int centerColor, int endColor)
	{ 
		int[] colors = new int[]{startColor, centerColor, endColor};
		GradientDrawable gd = new GradientDrawable(orientation, colors);
		return gd;
	} 
	 
	private Drawable getWheelValDrawable()
	{ 
		return makeGradientDrawable(Orientation.BOTTOM_TOP, 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setColor, setCornerRadius, setStroke
     */ 
    @SuppressWarnings("deprecation") 
    @SuppressLint("NewApi") 
    public void setPopupColor(final int backgroundcolor, final int bordercolor, final int borderwidthDPI, final int textcolor, float cornerradiusDPI) {
 
        final GradientDrawable popupbackground = new GradientDrawable();
        popupbackground.setCornerRadius(cornerradiusDPI * getResources().getDisplayMetrics().density);
        popupbackground.setStroke((int) (borderwidthDPI * getResources().getDisplayMetrics().density), bordercolor);
        popupbackground.setColor(backgroundcolor);
 
        if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
            mScrollIndicatorText.setBackgroundDrawable(popupbackground);
        else 
            mScrollIndicatorText.setBackground(popupbackground);
 
        mScrollIndicatorText.setTextColor(textcolor);
    } 
 
    /** 
     * Sets the width and height of the TextView containing the indicatortext. Default is WRAP_CONTENT, WRAP_CONTENT. 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setCornerRadius, setGradientRadius, setShape
		mDrawSelected = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
				new int[] { 0x77FFFFFF, selectedColor,selectedColor,selectedColor,selectedColor, 0x77000000 });
		mDrawSelected.setShape(GradientDrawable.RECTANGLE);
		mDrawSelected.setGradientRadius((float)(Math.sqrt(2) * 60));
		mDrawSelected.setCornerRadius(8);
		mDrawPressed = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
				new int[] { 0x77FFFFFF, pressedColor,pressedColor,pressedColor,pressedColor, 0x77000000 });
		mDrawPressed.setShape(GradientDrawable.RECTANGLE);
		mDrawPressed.setGradientRadius((float)(Math.sqrt(2) * 60));
		mDrawPressed.setCornerRadius(8);
 
		drawable.addState(new int[]{ statePressed}, mDrawPressed);
		drawable.addState(new int[]{ stateFocused, stateWindowFocused}, mDrawSelected);
		drawable.addState(new int[]{stateFocused, -stateWindowFocused}, null);
		drawable.addState(new int[]{-stateFocused, stateWindowFocused}, null);
		drawable.addState(new int[]{-stateFocused, -stateWindowFocused}, null);
		return drawable;
	} 
	private static Drawable oldSelector(Context context, int type){
		//int selectedColor=MyLauncherSettingsHelper.getHighlightsColorFocus(context); 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android GradientDrawable Questions & Answers:

See Code Examples for Android GradientDrawable Methods: