フォルダーアセットから取得したカスタムフォントを使用するカスタムテキストビューを作成しました。これは私が書いたクラスです:
public class TextViewBold extends TextView
{
private void init()
{
Typeface face = Typeface.createFromAsset(getContext().getAssets(),"fonts/droid-sans.bold.ttf");
setTypeface(face);
setTextSize(14);
setTextColor(getContext().getResources().getColor(R.color.black));
}
public TextViewBold(Context context)
{
super(context);
init();
}
public TextViewBold(Context context, AttributeSet attrs)
{
super(context, attrs);
init();
}
}
また、TextView を拡張する 2 つの他のクラスを作成し、それを xml レイアウトで呼び出します。
<com.cmc.xcharge.widget.TextViewBold
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ff00ff"
android:text="hello" />
私は成功をビルドして実行しますが、この行: com.cmc.xcharge.widget.TextViewBold は長すぎて使用できず、次のように使用したい:
<TextViewBold
/>
私は何をすべきか?