【问题标题】:How to change the font size of the application from setting preference?如何从设置首选项更改应用程序的字体大小?
【发布时间】:2011-09-07 05:11:46
【问题描述】:

在我的应用程序中,我想在设置首选项中提供添加字体大小,例如 18、20、22,这样用户选择 20,那么整个应用程序应该只使用该字体大小。如何做到这一点?

【问题讨论】:

标签: android font-size


【解决方案1】:

您可以在表单中定义设置代码,然后这样做:

 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

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-09
    • 1970-01-01
    • 1970-01-01
    • 2011-09-03
    • 2018-09-26
    • 1970-01-01
    • 2020-10-20
    • 1970-01-01
    相关资源
    最近更新 更多