1
私はカスタムフォントのテキストビューを作りたがっていました。Fragment Android Studioでカスタムフォントが動作しない
私はFragEarnCredits.javaに持っている:
<TextView
android:id="@+id/logo"
android:text="Fashion Wallet"
android:gravity="center"
android:textSize="40dp"
android:textColor="@color/md_brown_700"
android:layout_marginTop="100dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
/>
そして、私がnullエラーを取得しています:fragment_earn_credits.xmlで
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (aiView == null) {
aiView = inflater.inflate(R.layout.fragment_earn_credits, container, false);
}
t = (TextView) aiView.findViewById(R.id.logo);
Typeface myCustomFont=Typeface.createFromAsset(aiContext.getAssets(),"fonts/bebas.otf");
t.setTypeface(myCustomFont);
。どうして?みんな助けて!
Typeface myCustomFont=Typeface.createFromAsset(aiContext.getAssets(),"fonts/bebas.otf");
に
Typeface myCustomFont = Typeface.createFromAsset(getActivity().getAssets(), "fonts/bebas.otf");
そして0エラーが、フォントが変更されていません。
#EDIT
は私が変更しようとしました。
@aaooが動作しません。 0エラーが発生し、フォントが変更されていない –
@FootballFan、別のフォントを試して、フォントファイルが大丈夫かどうか確認できますか? –
@aaoo働いています、私はPhotoshopを使用しています –