Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1543956
  • 博文数量: 237
  • 博客积分: 5139
  • 博客等级: 大校
  • 技术积分: 2751
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-18 14:48
文章分类

全部博文(237)

文章存档

2016年(1)

2012年(4)

2011年(120)

2010年(36)

2009年(64)

2008年(12)

分类: 嵌入式

2011-06-22 17:58:04

        在android中,都推荐使用自适应大小的dip为单位,则一个42*42的png图片在HWVGA(800*480)的屏上,density为1.5,占有的图像pixel是63*63,其实是42dp

       DisplayMetrics dm=new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);   
        float width=dm.widthPixels*dm.density;   
         float height=dm.heightPixels*dm.density;
         Resources res = getResources(); 
         Drawable shape = getResources(). getDrawable(R.drawable.lock_freemium); 
         width=shape.getIntrinsicHeight();
         height=shape.getIntrinsicWidth();


阅读(1084) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~