最近我决定更新我的旧应用,但收到错误native typeface cannot be made
。我之前没有得到它。为了测试它是否在该特定项目中出现了一些小故障,我创建了一个新的,我实现了自定义字体,但错误是相同的。
这是我的MainActivity.java:
public class MainActivity extends Activity {
Typeface MontBold;
Typeface AsapBold;
TextView txt1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MontBold = Typeface.createFromAsset(getAssets(), "fonts/Montserrat-Bold.ttf");
AsapBold = Typeface.createFromAsset(getAssets(), "fonts/Asap-Bold.otf");
txt1 = (TextView) findViewById(R.id.txt1);
txt1.setTypeface(AsapBold);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
字体位置
Logcat错误
答案 0 :(得分:0)
我认为这里有一个错字。从资产创建时,您提供了错误的字体名称。它应该是“Montserrat-Bold.otf”。