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);
}
}
カスタムフォントを使用するために、このようなテキストビューがあります。問題は、それを正当化することです。次のような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>"));
しかし、うまくいきません。透明な背景は webview のバグであるため、web-view を使用しないことを好みますが、背景を透明にする必要があります。
どうもありがとう。