在源码androidframeworksasecorejavaandroidcontent es Configuration.java下有读取DEFAULT_FONTSCALE的值,如果没有定义这个值就用缺省的值fontScale = 1.0f;
代码如下:
/** * Set this object to the system defaults. */ public void setToDefaults() { String scale = Build.DEFAULT_FONTSCALE; if ( scale.equalsIgnoreCase( Build.UNKNOWN ) == false ) { fontScale = Float.valueOf( Build.DEFAULT_FONTSCALE ).floatValue(); } else { fontScale = 0.85f;//add by wangjian 2014.01.16 //fontScale = 1.0f;//default value } mcc = mnc = 0; locale = null;
我后来加的代码: fontScale = 0.85f;
这个值 Build.DEFAULT_FONTSCALE
在androidframeworksasecorejavaandroidosBuild.java中有定义:
/**a property to tablet systemUI */ public static final String TABLETUI = getString("ro.property.tabletUI"); /**a property to tablet systemUI */ public static final String DEFAULT_FONTSCALE = getString("ro.property.fontScale");
而这个设置: ro.property.fontScale
是在androiddevicesoftwinnerwing-k70wing_k70.mk中定义,代码如下:
# ui PRODUCT_PROPERTY_OVERRIDES += ro.property.tabletUI=false ro.sf.lcd_density=160 ro.property.fontScale=0.85
而源码里提供可供选择的值在代码 androidpackagesappsSettings
esvaluesarrays.xml中:
<string-array name="entryvalues_font_size" translatable="false"> <item>0.85</item> <item>1.0</item> <item>1.15</item> <item>1.30</item> </string-array>