gpt4 book ai didi

android - 如何为 Galaxy S3 和 Nexus 7 创建不同的布局?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:09:46 26 4
gpt4 key购买 nike

我已经创建了一个适用于 nexus 7 的 android 应用程序。在资源文件夹中,我为 Nexus 7"选项卡创建了两个文件夹,layoutlayout-land。到目前为止一切正常。现在我想创建一个不同的布局对于三星 Galaxy S3。为此,我在资源内创建了一个文件夹,其中包含 layout-largelayout-large-land。但是,这就是问题所在。现在,对于Nexus 7 也在加载 layout-large 文件夹中定义的布局。如何停止?如何为 Nexus 7"选项卡和 Galaxy S3 移动设备创建不同的布局?我读过Supporting Multiple Screens文档。但我无法理解,因为 Nexus 7 的屏幕尺寸是 1204 X 800,而三星 galaxy S3 的屏幕尺寸是 720 X 1280。

如何为具有不同屏幕分辨率和显示尺寸的不同设备创建不同的布局?此外,根据设备大小,我想在我的应用程序中更改几个值。如何做到这一点?

最佳答案

根据Supporting Multiple Screens enter image description here

smallnormallargexlarge 等限定符用于屏幕尺寸,这意味着 Nexus 7 将使用带有 large 限定符的资源(如果您提供的话)。因此,在您使用 large 限定符创建文件夹之前,Nexus 7 将从默认布局文件夹加载资源。至于ldpimdpihdpixhdpi 是屏幕密度。

要解决您的问题,您需要:

  1. 将Galaxy S3 的布局定义放入layout,将Nexus 7 的layout-sw600dp 放入layout-sw600dp。请引用Android 开发者博客:Getting Your App Ready for Jelly Bean and Nexus 7

  2. 将 Galaxy S3 的资源(图像或可绘制内容)放入 drawable-xhdpi,以及用于 Nexus 7 的 drawable-tvdpi 或 drawable-hdpi。

希望对您有所帮助,如果您还有其他问题,请告诉我:)

这里有一些有用的引用资料:

What layout is suitable for 720x1280 Android devices?

Screen Width Qualifier

关于android - 如何为 Galaxy S3 和 Nexus 7 创建不同的布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12816169/

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