2012-03-04 23 views
1

我對android中的字體有疑問。我想爲書寫的字體着色,以便每個鍵入的字母必須以兩種顏色顯示(紅色字母的下半部分和黃色字母的上半部分)。我想知道這是否可行?在android中爲鍵入的字母顏色

有什麼建議嗎?

+0

也許最好的解決辦法是把這段文字到圖片和'ImageView'顯示。 – skywall 2012-03-04 20:47:19

+0

不,我不想使用圖像 – Developer 2012-03-04 20:57:48

回答

1

嘗試:

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); 
相關問題