如何从设置首选项更改应用程序的字体大小?

问题描述:

在我的应用程序中,我想在设置首选项中添加字体大小(例如18,20,22),以便用户选择20,然后整个应用程序应仅使用该字体大小。如何实现这一目标?如何从设置首选项更改应用程序的字体大小?

+0

这里http://*.com/a/12591991/746347见我的答案 – mixel 2012-09-25 22:31:08

你可以在你的形式定义的设置代码,做这样的:

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 

}