在调试产品的时候经常会遇到因为LCD屏分辨率不一样而导致UI显示过大或过小的情况,修改了属性系统中的变量ro.sf.lcd_density(device_base.mk),根据对应的屏幕增大或减小对应的值,问题一般都能解决。
在frameworks/base/core/java/android/util/DisplayMetrics.java文件中会去获取这个属性的值
public static final int DENSITY_DEVICE = getDeviceDensity();
private static int getDeviceDensity() {
// qemu.sf.lcd_density can be used to override ro.sf.lcd_density
// when running in the emulator, allowing for dynamic configurations.
// The reason for this is that ro.sf.lcd_density is write-once and is
// set by the init process when it parses build.prop before anything else.
return SystemProperties.getInt("qemu.sf.lcd_density",
SystemProperties.getInt("ro.sf.lcd_density", DENSITY_DEFAULT));
}
density表示显示密度,表示每英寸有多少个显示点,但是这个显示点与