美文网首页
无标题文章

无标题文章

作者: bruceyag | 来源:发表于2015-02-16 18:19 被阅读0次

1.一般情况:

在xml布局文件当中统一采用线性布局和相对布局,单位采用sp和dp ,包括代码中进行合理转换,一般都不会存在什么问题

在代码里设置的高宽值都是像素 (px) 所以我们需要将自己设置的值dip转换为代码中定义的px以此来适应不同手机的适配

为了适配各种手机不同的分别率,一般安卓的单位都采用dip(dp),和sp(字体的单位) 。有关单位的区别详见http://www.jb51.net/article/38506.htm

这里我们用一工具类 densityutil(详见wiki工具包) 可以进形px和dip之间的转换

 eg.       
            int dip = 60;
            int px = DensityUtil.dip2px(AppMangerActivity.this,dip);
            popupWindow.showAtLocation(parent, Gravity.LEFT | Gravity.TOP , px, location[1]); //定义窗体的显示位置和

2.特殊情况,有时候需要有的手机屏幕很小,如果按照上面的方法设计,就会使得手大的人操作不方便,那么针对特殊机器的特殊分辨率我们可以在创建一个布局文件,安卓系统 在安装程序时会自动识别的去选择合适的布局

如图 mdpi(低分辨率) ldpi(中等分辨率)hdpi(高分辨率) hdpi -960*540(高 分辨率特殊屏幕的机器)

:

相关文章

  • 无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章 无标题文章无标题文章无标题文章无...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • fasfsdfdf

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章

  • 无标题文章

    无标题文章 无标题文章 无标题文章无标题文章 无标题文章 无标题文章

网友评论

      本文标题:无标题文章

      本文链接:https://www.haomeiwen.com/subject/htkyxttx.html