カスタム ボタン、TextView、および ImageView を作成しました。これらのいずれも、XML のグラフィカル レイアウトで適切に表示されません。カスタム フォントでボタンやテキストを表示する代わりに、呼び出しているカスタム クラスの名前を示す巨大な灰色のボックスが表示されます。これらをプレビューに表示するにはどうすればよいですか?
public class FontTextView extends TextView {
public static Typeface FONT_NAME;
public FontTextView(Context context) {
super(context);
if(FONT_NAME == null) FONT_NAME = Typeface.createFromAsset(context.getAssets(), "font.ttf");
this.setTypeface(FONT_NAME);
}
public FontTextView(Context context, AttributeSet attrs) {
super(context, attrs);
if(FONT_NAME == null) FONT_NAME = Typeface.createFromAsset(context.getAssets(), "font.ttf");
this.setTypeface(FONT_NAME);
}
public FontTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if(FONT_NAME == null) FONT_NAME = Typeface.createFromAsset(context.getAssets(), "font.ttf");
this.setTypeface(FONT_NAME);
}
と
<com.example.gesturetest.FontTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text placeholder" />