Code example for GradientDrawable

Methods: setCornerRadius

0
		return makeBackgroundDrawable(bgColor, computedRadius, strokeBottom, strokeTop, bottom, top);
	} 
	 
	protected Drawable makeBackgroundDrawable(int bgColor, float radius, int strokeBottom, int strokeTop, int bottom, int top) {
		GradientDrawable base = makeGradient(bgColor, bgColor);
		base.setCornerRadius(radius+displayUtils.getDIP(2)); // Add 2 pixels to make it look nicer
		 
		GradientDrawable stroke = makeGradient(strokeBottom, strokeTop);
		stroke.setCornerRadius(radius+displayUtils.getDIP(1)); // Add 1 pixel to make it look nicer
		 
		GradientDrawable background = makeGradient(bottom, top);
		 
		background.setCornerRadius(radius);
		 
		LayerDrawable layers = new LayerDrawable(new Drawable[] {base, stroke, background});
		 
		layers.setLayerInset(1, 1, 1, 1, 1);
		layers.setLayerInset(2, 2, 2, 2, 2);	
		 
		return layers;
	} 
	 
	protected OnClickListener getOnClickListener() {
		return new OnClickListener() {
			@Override 
			public void onClick(final View v) {
				 
				if(beforeListeners != null) {
					for (OnClickListener listener : beforeListeners) {
						listener.onClick(v);
					} 
				} 
				 
				if(customClickListener != null) {
					customClickListener.onClick(v);
				} 
				 
				if(afterListeners != null) {
					for (OnClickListener listener : afterListeners) {
						listener.onClick(v);
					} 
				} 
			} 
		}; 
	} 
	 
	// use a method so we can mock 
	protected ImageView makeImageView() {
		return new ImageView(getContext());
	} 
	// use a method so we can mock 
	protected TextView makeTextView() {
		return new TextView(getContext());
	} 
	// use a method so we can mock 
	protected LayoutParams makeLayoutParams(int width, int height) {
		return new LinearLayout.LayoutParams(width, height);
	} 
 
	protected GradientDrawable makeGradient(int bottom, int top) {
		return new GradientDrawable(
				GradientDrawable.Orientation.BOTTOM_TOP,
				new int[] { bottom, top });
	} 
	 
	public void setDrawables(Drawables drawables) {