屏幕适配方案系列一

  • 1.推荐方案:

    • 1)Android中的RelativeLayout, layout_weight属性,适应不同像素密度的dp/sp单位,mdpi/hdpi/xdpi等一系列文件夹,尽量用点九图,提供了各种手段解决适配问题
    • 2)可能的问题原因:android本身会根据手机的像素密度,会在不同的文件夹,选取对应的图片,并对图片进行放缩。但是由于android像素密度算法不科学,会导致同一张图在不同的像素密度的手机下,显示不一致。
    • 3)可行性的解决方案:只用一套图,就是用android的像素密度的逆运算,将图片尺寸还原到原始尺寸。判断当前手机的分辨率和原始参考系的分辨率的比例系数,乘以这个系数,给控件添加一个新的属性,就是百分比。因为百分比才是绝对不变的
    • 4)根据屏幕的尺寸动态的设置+符合各段位分辨率的图片
    • 5)为不同的分辨率设计不同的UI界面
  • 2.
    官网推荐方法
    http://developer.android.com/training/basics/supporting-devices/screens.html
    支持不同的屏幕
    http://developer.android.com/training/multiscreen/index.html
    资源匹配算法
    http://developer.android.com/guide/topics/resources/providing-resources.html#BestMatch
    图标设计
    https://www.google.com/design/spec/style/icons.html#icons-system-icons

    • 2.1.two general properties: size and density,support alternative resources
    • 2.2.four generalized sizes: small, normal, large, xlarge 布局
    • 2.3. four generalized densities: low (ldpi), medium (mdpi), high (hdpi), extra high (xhdpi)图片
    • 2.4. layouts and bitmaps 使用,横竖屏先不考虑
    • 2.5.创建不同的布局,比如large-size的屏幕,则后缀名suffix添加-
    • 2.6.Android automatically scales your layout in order to properly fit the screen.
    • 2.7.

      The file names must be exactly the same, but their contents are different in order to provide an optimized UI for the corresponding screen size.布局内容可以不相同,但是名字要相同,这样Android会根据屏幕大小时会自动加载选择合适的布局The system loads the layout file from the appropriate layout directory based on screen size of the device
    • 2.8.

      Android 3.2版本以上有更好的方法根据 allows you to specify【指定】 resources for screen sizes based on the minimum width and height 【最小宽度和高度】in terms of density-independent pixels. 【dpi】
    • 2.9.图片:scaled to each of the generalized density buckets: low, medium, high and extra-high density. Any time you reference @drawable/awesomeimage, the system selects the appropriate bitmap based on the screen’s density. 系统会根据屏幕密度自动选择
    • 2.10.兼容不同的屏幕大小也就是适配支持:design your application to be compatible with all screen sizes
  • 3.官方推荐方法——高阶

    • 3.1.兼容不同屏幕大小的基本指导原则:
      • 01.布局可以被重新计算 be adequately resized to fit the screen!
    • -02.Providing appropriate UI layout according to screen configuration
    • -03.Providing bitmaps that scale correctly 设计师提供层裁剪合适的位图
    • 3.2.具体方案原则:
    • -01.尽量使用”wrap_content” and “match_parent”属性来定义视图组件的宽和高
      “wrap_content”:the width or height of the view is set to the minimum size necessary to fit the content within that view
      “match_parent”:makes the component expand to match the size of its parent view. 大小size,而不是使用hard-coded sizes
    • -02.LinearLayout does not allow you to precisely control the spacial relationships of child views; views in a LinearLayout simply line up side-by-side. If you need child views to be oriented in variations other than a straight line, a better solution is often to use a RelativeLayout, 推荐使用相对布局
    • -03.使用配置符configuration qualifiers
      http://developer.android.com/guide/practices/screens_support.html#qualifiers

      Android3.2之后
    • -04.使用点9图制作图标背景
      http://www.zhihu.com/question/28850798/answer/42476544
      http://blog.csdn.net/lmj623565791/article/details/46695347
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值