Horizontal LinearGradient avec android

Mots clés : androidandroid

meilleur 2 Réponses Horizontal LinearGradient avec android

vote vote

90

int x1 = 0, y1 = 0, x2 = 0,  y2 = 40; 
Shader shader = new LinearGradient(0, 0, 0, 40, Color.WHITE, Color.BLACK, TileMode.CLAMP); Paint paint = new Paint();  paint.setShader(shader);  canvas.drawRect(new RectF(0, 0, 100, 40), paint);  
vote vote

86

LinearGradient(0, 0, 0, height, gradientStartColor, gradientEndColor, Shader.TileMode.CLAMP) 
LinearGradient(0, height, 0, 0, gradientStartColor, gradientEndColor, Shader.TileMode.CLAMP) 
LinearGradient(0, 0, width, 0, gradientStartColor, gradientEndColor, Shader.TileMode.CLAMP) 
LinearGradient(width, 0, 0, 0, gradientStartColor, gradientEndColor, Shader.TileMode.CLAMP) 

Questions similaires