开发者

Android - Gridview or listview?

How do i create this kind of views in my application? (The screenshot is actually of an android application available in and开发者_JAVA技巧roid market).

Android - Gridview or listview?

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.


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

    < bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/shelf_panel" android:tileMode="repeat" />

  • background image is like this:

    Android - Gridview or listview?

The code is worth a look because it contains other interesting solutions, too.


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?


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:

Android - Gridview or listview?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜