gpt4 book ai didi

java - 安卓应用程序 : Can I show products different in a 7 inch tablet from a 10 inch tablet?

转载 作者:行者123 更新时间:2023-12-02 07:05:29 26 4
gpt4 key购买 nike

编辑:这不是重复的帖子。我不是问如何为 Android 实现不同的布局分辨率,而是如何动态列出不同分辨率的产品,以便它们填充所需的空间。目前,10英寸显示屏上显示4排产品,7英寸显示屏上显示4排产品。这意味着用户需要在 7 英寸屏幕上垂直滚动才能查看所有内容。我希望产品能够动态地填充空间,而不需要垂直滚动。感谢您提前提供的任何帮助。

我正在帮助编写一个 Android 应用程序。在 10 英寸平板电脑中,我显示了 4 行产品(这就是我想要的)。在 7 英寸中,我应该只显示 3 行产品,但现在显示 4 行(如 10 英寸平板电脑),这会导致垂直滚动。是否可以编写代码在 7 英寸平板电脑上仅显示 3 行?

我的产品仅按预期左右移动 - 它不应该有垂直滚动。

更具体地说,问题是:是否可以动态渲染产品,在 10 英寸平板电脑上显示 4 行产品,而在 7 英寸平板电脑上仅显示 3 行产品。 7英寸选择的布局较大。

最佳答案

您需要 7 英寸和 10 英寸的单独布局

适用于 7 英寸平板电脑

  • 布局-sw600dp

  • 布局-sw600dp-端口

适用于 10 英寸平板电脑

  • 布局-sw720dp

  • 布局-sw720dp-端口

更新示例

res/layout this is the default, it is needed even if you don't plan to support phones!

适用于 3.2 及以上版本 Android 版本 ( >= 3.2 )

res/layout/main_activity.xml           # For handsets (smaller than 600dp available width)

res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger)

res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wide and bigger)

适用于低于 3.2 版本的 Android 版本 ( < 3.2 )

res/layout-large                       # for 7" tablet (works on emulator and nexus7)

res/layout-xlarge # for 10" tablet (works on emulator and galaxytab10.1)

关于java - 安卓应用程序 : Can I show products different in a 7 inch tablet from a 10 inch tablet?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16176481/

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