Android:系统分辨率的修改

分辨率修改涉及两个概念:密度和尺寸

 

每个项目密度定义路径:

customize/customer_cfg/sp8810ga/res/system.prop

 

# 1 => add volume control in in-call screen
ro.sprd.volume_control_icon = 1

#LCD_Density for WGVA
ro.sf.lcd_density =240

dalvik.vm.heapsize=32m

ro.opengles.version=131072

 

搜索ro.sf.lcd_density关键字,

device/samsung/system.prop,vendor/sprd/hsdroid/system.prop

也有定义!

验证结果:

最终生成的build.prop文件

#LCD_Density for WVGA
ro.sf.lcd_density = 240

来自customize下的修改值!

手机目录system/build.prop通过adb导出来,

修改其中的值,再push进相应目录下的build.prop,重新开机,显示预先效果!

 

尺寸修改:

 

frameworks/base/core/java/android/content/res/CompatibilityInfo.java


    publicstatic final int DEFAULT_PORTRAIT_WIDTH = 320;


    publicstatic final int DEFAULT_PORTRAIT_HEIGHT = 480;

 

四组数据效果比较:

1)、正常效果:

DEFAULT_PORTRAIT_WIDTH = 320;DEFAULT_PORTRAIT_HEIGHT =480;ro.sf.lcd_density = 240;

2)、正常效果:

DEFAULT_PORTRAIT_WIDTH = 480;DEFAULT_PORTRAIT_HEIGHT =800;ro.sf.lcd_density = 240;

3)、界面显示正常,系列显示图标变小:

DEFAULT_PORTRAIT_WIDTH = 480;DEFAULT_PORTRAIT_HEIGHT =800;ro.sf.lcd_density = 160;

4)、部分界面显示不全(如锁),系列显示图标变小:

DEFAULT_PORTRAIT_WIDTH = 320;DEFAULT_PORTRAIT_HEIGHT =480;ro.sf.lcd_density = 160;

 

结论:

ro.sf.lcd_density影响分辨率的关键因素,

目前四个等级的屏幕密度等级,

决定每个APK选取res下的不同资源文件。

如主流屏幕drawable-hdpi(密度240)、drawable-mdpi(密度160)等;

 

相关说明:

frameworks/base/core/java/android/util/DisplayMetrics.java

private static int getDeviceDensity() {
       // qemu.sf.lcd_density can be used to overridero.sf.lcd_density
       // when running in the emulator, allowing for dynamicconfigurations.
       // The reason for this is that ro.sf.lcd_density is write-once andis
       // set by the init process when it parses build.prop beforeanything else.
       return SystemProperties.getInt("qemu.sf.lcd_density",
               SystemProperties.getInt("ro.sf.lcd_density",DENSITY_DEFAULT));
    }

 

frameworks/base/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp

    #
    if(property_get("qemu.sf.lcd_density", property, NULL)<= 0) {
       if (property_get("ro.sf.lcd_density", property, NULL)<= 0) {
           LOGW("ro.sf.lcd_density not defined, using 160 dpi bydefault.");
           strcpy(property, "160");
       }
    } else{
      
       mDpiX = mDpiY = atoi(property);
    }

上面表示:

如果没有设置ro.sf.lcd_density的值,那么选择DENSITY_DEFAULT的默认定义;

再看DENSITY_DEFAULT定义处:


    #
    publicstatic final int DENSITY_LOW = 120;

    #
    publicstatic final int DENSITY_MEDIUM = 160;

    #
    publicstatic final int DENSITY_HIGH = 240;

    #
    publicstatic final int DENSITY_XHIGH = 320;

    #
    publicstatic final int DENSITY_DEFAULT = DENSITY_MEDIUM;

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值