屏幕适配三 (使用)

支持多种屏幕的目标是创建一款在 Android 系统支持的通用屏幕尺寸上都可以 正常运行且显示良好的应用。

使用“wrap_content”和“match_parent”

为确保您的布局能够灵活地适应不同的屏幕尺寸,您应该为某些视图组件的宽度和高度使用 “wrap_content” 和 “match_parent”。 如果您使用 “wrap_content”,视图的宽度或高度将设置为使内容适应该视图所需的最小尺寸,而 “match_parent” 会使组件通过扩展来匹配其父视图的尺寸。

使用尺寸限定符
res/layout/main.xml
res/layout-large/main.xml (在屏幕归类为大屏幕的设备,低于 3.2 版本)
res/layout-sw600dp/main.xml (最小宽度大于或等于 600dp 的设备,高于 3.2 版本)
使用布局别名
res/layout/main.xml,单窗格布局
res/layout/main_twopanes.xml,双窗格布局
使用屏幕方向限定符

res/values/layouts.xml:

<resources>
<item name="main_layout" type="layout">@layout/onepane_with_bar</item>
<bool name="has_two_panes">false</bool>

res/values-sw600dp-land/layouts.xml:

<resources>
<item name="main_layout" type="layout">@layout/twopanes</item>
<bool name="has_two_panes">true</bool>

res/values-sw600dp-port/layouts.xml:

<resources>
<item name="main_layout" type="layout">@layout/onepane</item>
<bool name="has_two_panes">false</bool>

使用九宫格位图

支持不同屏幕尺寸通常意味着您的图像资源也必须能够适应不同的尺寸。
例如,按钮背景必须能够适应其所应用到的任何一种按钮形状

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值