gpt4 book ai didi

Android 资源限定符 -sw#dp 与 -w#dp

转载 作者:IT老高 更新时间:2023-10-28 21:57:38 30 4
gpt4 key购买 nike

假设我正在为屏幕尺寸等于或大于 600dp 的设备开发不同的布局。我想使用 post android 3.2 资源限定符。我创建了一个名为 layout-sw600dp 的文件夹并将我的布局放在那里,但同时我可以创建一个名为 layout-w600dp 的文件夹并将布局 xml 文件放在那里.我想弄清楚 -sw600dp-w600dp 有什么区别?毕竟它们都是为了使用宽度> = 600dp的设备的布局。

最佳答案

sw是“最小宽度”。如果设备旋转,它不会改变。

w ,另一方面,可用(即当前)宽度。

Providing Alternative Resources :

smallestWidth - sw<N>dp - The smallestWidth is a fixed screen size characteristic of the device; the device's smallestWidth does not change when the screen's orientation changes.

Available width - w<N>dp - This configuration value will change when the orientation changes between landscape and portrait to match the current actual width.

示例。假设您有一台 600dp x 400dp 的设备。

  • 如果您有 w600dp 资源,它将用于横向,而不是纵向。
  • 如果您有 sw600dp 资源,它不会用于任何方向(最小为 400)。

关于Android 资源限定符 -sw#dp 与 -w#dp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24579608/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com