【发布时间】:2015-06-12 13:22:06
【问题描述】:
问题
我想要一个特殊的 UI,它类似于 Windows 8 Tiles UI,具有不同大小的单元格。
类似这样的:
AABB
AACC
AADD
AADD
每个字母代表其单元格的一部分,因此单元格 A 为 2x4 ,单元格 B 和单元格 C 各取 2x1 ,单元格 D 为 2x2。
Laucher 8 就是一个很好的例子。
我不想使用网格布局。
我正在使用 GridView,但无法使用 GridView 实现上述布局。
问题
1. I have a framelayout as the items in the adapter.
Using Linear Layout instead of adapter supporting view will certainly
make it boring
or
May be I am wrong about Linear Layout.
2. Can such a layout be achieved through GridView.
3. How [Laucher 8][2]. is achieving that.
编辑
My problem was solved using https://github.com/lucasr/twoway-view/ . Google's
staggeredViewGridLayoutManager didn't help may be because I didn't found
it's good usage documentation and I was not able to layout the items in the
Layout in my desired location.
【问题讨论】:
-
“我不想使用网格布局”——为什么?如果你解释为什么一个明显的选择是你不想要的东西,它将帮助其他人给你更好的建议。 “这样的布局能不能通过GridView来实现。” - 不。
GridView单元格大小一致。 “[Laucher 8][1] 是如何实现这一目标的”——使用uiautomatorviewer并找出答案。除此之外,您所指的通常称为“交错网格”,可以使用RecyclerView和各种开源库创建一个。 -
谢谢@CommonWare。 GridLayout 是非常新的布局,恐怕它不会在旧的 android 版本中运行。不知道 uianimatorViewer。
-
“GridLayout 是一个非常新的布局”——它已经存在了四年。 “恐怕它不会在旧的 android 版本中运行”——Android 支持包中提供的
gridlayout-v7反向移植可以追溯到 API 级别 7,它涵盖了 99+% 的活动 Android 设备。 -
@CommansWare,在互联网的某个地方,我错误地读到 Gridlayout 支持 API 17。我的错。如果我使用 GridLayout,我将不得不定义每个图块的每个位置和大小。此外,我正在使用大约 100 多个瓷砖。此外,我的移动 API 级别低于 16,因此无法使用 uiautomatorviewer。但我明白了。
-
@dberm22 不,它不重复。我不希望我的布局是 pinterest 风格的。
标签: android android-layout android-linearlayout android-gridview android-launcher