Android - Gridview 还是 listview?
如何在我的应用程序中创建这种视图? (该屏幕截图实际上是 Android 市场中可用的 Android 应用程序)。
我很困惑,因为我假设我们可以使用 Gridview 或使用来创建相同类型的布局列表视图。
问题:
- 在Gridview中,我们可以在两行之间给出分隔符吗?我们可以为 gridview 中的每一行提供背景吗?
- 在Listview中,我认为我们可以自定义带有背景的连续3本书的listview,并且我们也可以给出分隔符。
从您的专家角度,请建议我一个可能的解决方案来为 Android 应用程序设计和创建相同类型的布局。
How do i create this kind of views in my application?
(The screenshot is actually of an android application available in android market).
I am confused as i assume that we can create the same kind of layout either by using Gridview or by using ListView.
Problems:
- In Gridview, can we give separator between two rows? can we give background to each row in gridview?
- In Listview, i think we can customize the listview with 3 books in a row with background, and we can give a separator as well.
From your expert side, please suggest me a possible solution to design and create the same kind of layouts for the android application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
查看由 Romain Guy(ListView 的创建者之一)编写的 Shelves 的代码。
他使用了 GridView:
无分隔符
背景是可绘制的位图
<块引用>
<位图
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/shelf_panel"
android:tileMode="重复" />
背景图片是这样的:
该代码值得一看,因为它还包含其他有趣的解决方案。
Look at the code of Shelves, written by Romain Guy (one of the ListView's creator).
He used a GridView:
no separator
background is a bitmap drawable
background image is like this:
The code is worth a look because it contains other interesting solutions, too.
指出的问题:
在Gridview中,我们可以在两行之间指定分隔符吗?我们可以为 gridview 中的每一行提供背景吗?
嗯,您始终可以通过在视图底部添加一些内容来构成分隔符。让它在两侧“连接”,这样你就不会知道其中的区别。每个网格项目都会花费您额外的视图,所以可能不是最好的选择。
在Listview中,我认为我们可以自定义列表视图,连续3本书,带有背景,我们也可以给一个分隔符。
嗯,是的,虽然我不明白问题是什么?
Stated problems:
In Gridview, can we give separator between two rows? can we give background to each row in gridview?
Well, you can always make up a separator by adding something on the bottom of your view. Make it so that it 'connects' on the sides, and you won't know the difference. It will cost you an extra view per grid-item, so probably not the best option.
In Listview, i think we can customize the listview with 3 books in a row with background, and we can give a separator as well.
Eeuhm, yes, although I don't see what the problem is?
使用 ListView,每一行都被视为一个元素,因此需要额外的逻辑工作来保持行中的每个项目独立。我建议你使用网格视图。对于每个网格元素,保留一个空的书架空间(用于一本书)作为背景图像。该图像将包括货架底座。因此不需要额外的行。图像应如下所示:
With a ListView, each row is counted as an element, so there will be extra work in logic that keeps each item within the row separate. I would suggest you use a gridview. For each grid element, keep an empty shelf space (for one book) as the background image. This image will include the shelf-base. So there is no need for additional rows. The image should look like this:
如果书籍数量有限,我建议使用网格视图和视图翻转器。
视图翻转会比滚动提供更好的效果。
I would instead suggest to have grid view and view flipper if the number of books are limited.
View flipper will give a better effect than scrolling.