核心:
Configuration configuration = getResources().getConfiguration();
configuration.fontScale =ztSize;
//0.85 小, 1 标准大小, 1.15 大,1.3 超大 ,1.45 特大
DisplayMetrics metrics =new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
metrics.scaledDensity = configuration.fontScale * metrics.density;
getBaseContext().getResources().updateConfiguration(configuration, metrics);
部分:
private void init() {
setSize.setOnPointResultListener(new SetTextSizeView.OnPointResultListener() {
@Override
public void onPointResult(int position) {
// setSize.setTextAlignment(position + 1);
fontSzie = position +1;
if (fontSzie ==1) {//小号字体
ztSize =0.85f;
}else if (fontSzie ==2) {//标准字体
ztSize =1.0f;
}else if (fontSzie ==3) {//中号字体
ztSize =1.3f;
}else if (fontSzie ==4) {//大号字体
ztSize =1.5f;
}else if (fontSzie ==5) {//超大字体
ztSize =1.7f;
}else if (fontSzie ==6) {//巨大字体
ztSize =2f;
}
initFontScale();
}
});
}