我創建了下面的按鈕叫的Android編程按鈕字體不改變
Button loginButton = (Button) findViewById(R.id.login_button);
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Lato-Regular.ttf");
loginButton.setTypeface(tf);
我確定字體是在資產/字體。確切的文件名是:/ Users/myusername/Documents/GitHub/appname /app/src/main/assets/fonts/Lato-BoldItalic.ttf。
但是,按鈕上的字體仍然不會改變。這裏可能是什麼問題?
編輯:擴展的代碼
protected void onCreate(Bundle savedInstanceState) {
Parse.initialize(new Parse.Configuration.Builder(this)
.applicationId("###")
.server("https://parseapi.back4app.com/")
.clientKey("###")
.enableLocalDataStore()
.build()
);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
Button loginButton = (Button) findViewById(R.id.login_button);
Typeface tf = Typeface.createFromAsset(getAssets(), "Lato-Regular.ttf");
loginButton.setTypeface(tf);
more stuff
我試過這個,但它仍然不起作用。 :/我不確定可能存在什麼其他問題。 – chickenwings
它仍然不工作的原因:( – chickenwings
看到我的更新後 – Raja