Code example for LinearGradient

Methods: setShader

0
			mRedText.setText(Integer.toString(red)); 
			mGreenText.setText(Integer.toString(green)); 
			mBlueText.setText(Integer.toString(blue)); 
            redSeekBar.setProgress(red); 
            greenSeekBar.setProgress(green); 
            blueSeekBar.setProgress(blue); 
			mNewBoxBackground.getPaint().setShader(getPreviewBackground(newColor, mNewBoxBackground.getBounds())); 
			mPreviousBoxBackground.getPaint().setShader(getPreviewBackground(mPreviousColor, mPreviousBoxBackground.getBounds())); 
			mNewBoxBackground.invalidateSelf(); 
			mPreviousBoxBackground.invalidateSelf(); 
			broadcastColorChange(); 
		} 
 
	}; 
 
	/** 
	 * Returns a "glossy" background using the given color and the given bounds. Currently, 
	 * the gloss is applied vertically from top to bottom. 
	 * 
	 * @param color the color to be "glossed" 
	 * @param rect the bounds of the area to be glossed 
	 * @return a {@link android.graphics.LinearGradient} to be used for the background of a color preview 
	 */ 
	private LinearGradient getPreviewBackground(int color, Rect rect) {
		float[] hsv = new float[3];
		Color.colorToHSV(color, hsv);
		hsv[1] -= GLOSS_INTENSITY;
		hsv[2] += GLOSS_INTENSITY;
		int glossColor = Color.HSVToColor(hsv);
		return new LinearGradient(rect.left,
								  rect.top,
								  rect.left,
								  rect.bottom,
								  new int[] {color, glossColor, color},