屏幕适配
来源:互联网 发布:淘宝推广专区 编辑:程序博客网 时间:2024/05/24 04:10
关于屏幕布局适配建议
1、不要使用绝对布局
2、尽量使用match_parent 而不是fill_parent 。
3、能够使用权重的地方尽量使用权重(android:layout_weight)
4、如果是纯色背景,尽量使用android的shape 自定义。
5、如果需要在特定分辨率下适配,可以在res目录上新建layout-HxW.xml的文件夹。比如要适配1080*1800的屏幕(魅族MX3采用此分辨率)则新建layout-1800x1080.xml的文件夹,然后在下面定义布局。Android系统会优先查找分辨率相同的布局,如果不存在则换使用默认的layout下的布局。
代码实现
/** * 根据手机的分辨率从 dp 的单位 转成为 px(像素) */ public static int dip2px(Context context, float dpValue) { final float scale = context.getResources().getDisplayMetrics().density; return (int) (dpValue * scale + 0.5f); } /** * 根据手机的分辨率从 px(像素) 的单位 转成为 dp */ public static int px2dip(Context context, float pxValue) { final float scale = context.getResources().getDisplayMetrics().density; return (int) (pxValue / scale + 0.5f); }
0 0
- 【Android 屏幕适配】 屏幕适配
- Android 屏幕适配--屏幕旋转
- COCOS2DX屏幕显示与屏幕适配
- Android屏幕适配-----屏幕尺寸
- Android屏幕尺寸单位/屏幕适配
- 屏幕适配
- 【Android】屏幕适配
- android屏幕适配
- android屏幕适配
- android 屏幕适配
- Android屏幕适配
- Android屏幕适配
- Android屏幕适配
- Android屏幕适配
- android 屏幕适配
- 屏幕适配
- Android屏幕适配
- Android屏幕适配
- ScrollLayout
- Mac安装 RVM
- Hadoop之父Doug Cutting
- 射频识别技术漫谈(30)——PN512的寄存器设置
- ios 启动程序时隐藏状态栏,启动后显示状态栏
- 屏幕适配
- TinyOS论文01:T-Check:Bug Finding for Sensor Networks.
- 对话框与菜单的使用
- JVM解析01-平台无关性
- HTML5音乐播放器效果非常漂亮
- pAdTy_-5 保存数据
- java web 过滤器的执行先后顺序
- [Android Pro] 查看 keystore文件的签名信息 和 检查apk文件中的签名信息
- 架构:一主【生产-M】一副【管内-C】一酱油【管外-V】