使应用中的字体不受系统设置影响的两种方法

第一种

使用dp来设置文字的大小

第二种

private void keepFontSize(){
        Resources res = getResources();
        android.content.res.Configuration config = new android.content.res.Configuration();
        config.setToDefaults();
        res.updateConfiguration(config, res.getDisplayMetrics());
    }

并且,该方法必修在setContentView之前调用。这样在不改变项目原有字体设置(使用sp),就可以保持字体大小,而使排版不受系统字体设置影响。

你可能感兴趣的:(android,dp,字体,系统字体设置)