Code example for GradientDrawable

Methods: setDither, setGradientType, setShape

0
	public static void setGradientForPreferenceView(View v) {
 
		int[] colorsForGradient = new int[2];
		colorsForGradient[0] = Color.argb(0, 0, 0, 0);
		colorsForGradient[1] = Color.argb(64, 255, 255, 255);
		GradientDrawable d = new GradientDrawable(
				GradientDrawable.Orientation.LEFT_RIGHT, colorsForGradient);
		d.setGradientType(GradientDrawable.LINEAR_GRADIENT);
		d.setShape(GradientDrawable.RECTANGLE);
		// doesn't help d.setUseLevel(true); 
		d.setDither(true);
		v.setBackgroundDrawable(d);
	} 
 
	/** 
	 *  
	 * @param context 
	 * @param viewForPreference 
	 *            The View returned by super.onCreateView in the (custom) 
	 *            Preference class 
	 * @param indexOfMainWidget