【发布时间】:2011-09-07 05:11:46
【问题描述】:
在我的应用程序中,我想在设置首选项中提供添加字体大小,例如 18、20、22,这样用户选择 20,那么整个应用程序应该只使用该字体大小。如何做到这一点?
【问题讨论】:
-
在这里查看我的答案stackoverflow.com/a/12591991/746347
在我的应用程序中,我想在设置首选项中提供添加字体大小,例如 18、20、22,这样用户选择 20,那么整个应用程序应该只使用该字体大小。如何做到这一点?
【问题讨论】:
您可以在表单中定义设置代码,然后这样做:
private void loadSettings() {
//load font from global unit named G
G.typeFace = Typeface.createFromAsset(getAssets(), "fonts/BYekan.ttf");
TextView titleText = (TextView) findViewById(R.id.reg_title);
TextView regTitleText = (TextView) findViewById(R.id.reg_title);
TextView bigText = (TextView) findViewById(R.id.textView_big);
TextView button_titlet = (TextView) findViewById(R.id.reg_botton_title);
btnReg = (Button) findViewById(R.id.btn_reg);
titleText.setTypeface(G.typeFace);
bigText.setTypeface(G.typeFace);
regTitleText.setTypeface(G.typeFace);
button_titlet.setTypeface(G.typeFace);
btnReg.setTypeface(G.typeFace);
titleText.setTextSize(20);
bigText.setTextSize(20);
regTitleText.setTextSize(20);
button_titlet.setTextSize(20);
btnReg.setTextSize(20);
//end of fonts
}
【讨论】: