public class FontTextView extends TextView {
public FontTextView(Context context) {
super(context);
Typeface face = Typeface.createFromAsset(context.getAssets(),"palatino.ttf");
this.setTypeface(face);
}
public FontTextView(Context context, AttributeSet attrs) {
super(context, attrs);
Typeface face = Typeface.createFromAsset(context.getAssets(),"palatino.ttf");
this.setTypeface(face);
}
public FontTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
Typeface face = Typeface.createFromAsset(context.getAssets(),"palatino.ttf");
this.setTypeface(face);
}
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
}
}
我有这样的textview来使用自定义字体。问题是,我也想证明这一点。我试图使用这样的html代码:
testText.setText(Html.fromHtml("<html><head><div class=\"haodi_jianjie\";style=\"text-align:justify;text-justify:distribute-all-lines;color:white;background-color:black;\">asdsadsadsadsadsadsadsafsdvvbcvbcvb dfsdfsdgfgdfg gdfghththgfhgfhgfhgfhfghgfhgfhgf sdfsdfsdfsdfsdfsdfsfwqewqewq</div></head></html>"));
但这不起作用。我更喜欢不使用Web视图,因为透明的背景对于Web视图来说是有问题的,但是我需要背景是透明的。
非常感谢。
我们为此创建了一个简单的类。需要NO的WebView和SUPPORTS SPANNABLES。您也可以提供自己的自定义字体!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句