gpt4 book ai didi

android - 如何按大小摆放元素?

转载 作者:太空狗 更新时间:2023-10-29 13:18:52 24 4
gpt4 key购买 nike

目前,我正在开发一个安卓应用程序。在我的 Activity 中,我想根据元素的大小放置我的元素。我解释一下:我在 GridLayout 中有 3 个 LinearLayout,如下所示:

enter image description here

GridLayout (2,2, horizo​​ntal) 允许像这样放置 LinearLayouts :

enter image description here

我想做同样的事情,但不是用 GridLayout(2,2,horizo​​ntal),而是根据元素的大小。

例如,如果屏幕大,则可以将 3 个 LinearLayout 放在同一行,反之,如果屏幕小,则按行放置 1 个 LinearLayout。

我希望我已经清楚了,提前致谢。

最佳答案

此布局将是标准中不存在的“FlowLayout”。

但是周围有一些开源实现:

你应该看看

https://github.com/ApmeM/android-flowlayout

https://github.com/blazsolar/FlowLayout

关于android - 如何按大小摆放元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31534689/

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