2

I want this output:

enter image description here

The two colors are :

<color name="clrc2">#c27a1c</color>
    <color name="clrfe">#fee17f</color>

And i have tried this code :

Shader shader = new LinearGradient(0,100,10,100,
                new int[]{resources.getColor(R.color.clrc2),resources.getColor(R.color.clrfe),resources.getColor(R.color.clrc2)}
                ,new float[]{0.4f,0.2f,0.4f}, Shader.TileMode.MIRROR);
        option_.setTextColor(resources.getColor(R.color.clrc2));
        option_.getPaint().setShader( shader );

I am not achieving the desired result.

This is the result I get :

enter image description here

Parth Anjaria
  • 3,961
  • 3
  • 30
  • 62

1 Answers1

1

Got the accurate gradient by this code :

Shader textShader = new LinearGradient(0, 8, 0, 18,
            new int[]{Color.parseColor("#c27a1c"), Color.parseColor("#fee17f")},
            new float[]{0, 1}, Shader.TileMode.MIRROR);
    option_.setTextColor(resources.getColor(R.color.clrfe));
    option_.getPaint().setShader(textShader);

Ref from : https://stackoverflow.com/a/16958396/5327912

Parth Anjaria
  • 3,961
  • 3
  • 30
  • 62