我想添加自定義字體到我的android應用程序。這是我的代碼。誰能告訴我我哪裏錯了?添加自定義字體到Android應用程序
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView textview = (TextView) findViewById(R.id.FontTest);
Typeface tf = Typeface.createFromAsset(getApplicationContext()
.getAssets(), "fonts/snap-itc.ttf");
textview.setTypeface(tf);
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <TextView android:id="@+id/FontTest" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Font Test" android:textSize="50px"/> </RelativeLayout>
的代碼是罰款 –
代碼看起來不錯 – Ridcully
的代碼是好的...是ü得到任何錯誤或異常後的那 – nitesh