gpt4 book ai didi

android - 如何通过设置首选项更改应用程序的字体大小?

转载 作者:行者123 更新时间:2023-11-29 00:46:19 25 4
gpt4 key购买 nike

在我的应用程序中,我想在设置首选项中提供添加字体大小,例如 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

}

关于android - 如何通过设置首选项更改应用程序的字体大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6217235/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com