简体   繁体   English

Android字体在TTF中填充透明区域

[英]android typeface fill transparent areas in ttf

I'm using a ttf for my fonts in my app. 我在应用程序中使用ttf作为字体。 The font i'm using is like: http://www.dafont.com/unlearned-bitmap.font?nb_ppp=50 我使用的字体是: http : //www.dafont.com/unlearned-bitmap.font?nb_ppp=50

When i print text on a textview, the area in and around the strokes of the font is transparent, so i see only the black strokes of the font. 当我在textview上打印文本时,字体笔划及其周围的区域是透明的,因此我只能看到字体的黑色笔划。 When i set the backgroundcolor of the textview, the area inside the black strokes is colored, but also the area outside the strokes. 当我设置textview的backgroundcolor时,黑色笔触内部的区域被着色,但笔触外部的区域也被着色。 Is there a way to color the inside of the font, but not the area around the strokes? 有没有一种方法可以给字体内部着色,但不能给笔触周围的区域着色?

Yes, use setTextColor() 是的,请使用setTextColor()

Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "CustomFont.ttf");
setTypeface(tf);
yourTextView.setTextColor(Color.RED);
Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "AnyFont.ttf");
setTypeface(tf);
textview.setTextColor(this.getResources().getColor(R.color.orange));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM