Developer
Developer

Reputation: 1813

Color the typed letters in android

I have a question about fonts in android. I want to color the written font such that each typed letter must be displayed in two colors ( the lower half of the letter in red color and the upper part of the letter in yellow letter). I wonder if this is possible or not?

Any suggestions?

Upvotes: 1

Views: 158

Answers (1)

ρяσѕρєя K
ρяσѕρєя K

Reputation: 132982

try it:

EditText edtt=(EditText)findViewById(R.id.widget45);
Typeface tf=Typeface.createFromAsset(getAssets(),"LettersLaughingattheirExecution.ttf");
        edtt= (TextView)findViewById(R.id.CustomFontText);
       edtt.setTypeface(tf);

    Shader textShader=new LinearGradient(6, 0, 2, 60,
            new int[]{Color.parseColor("#666666"),Color.parseColor("#666666"),Color.parseColor("#b4e391")},
            new float[]{2, 0,1}, TileMode.MIRROR);
    edtt.getPaint().setShader(textShader);

Upvotes: 1

Related Questions