can someone help me and tell me is this possible in android. I need to have in my app a gridview alike widget, but with different item height and width, like this:
So is this possible, and if so, what can I use to achieve this.
Thanks
For this you need a work around or you can say a third party Library named as "AndroidStaggeredGrid"
You can check it on here
#Darko,
Yes, it it possible to do like this in Android.
There are many ways to implement this. As you said GridView cannot be used to achieve this. For a normal user this will appear has grids.
Ways:
Use fragment for each and every "grid" you can see and each fragment will have its layout to display either 2 or 3 images in grid (No gridview is required here too). Use ImageViews as usually.
If the layout design is same, then you can define a single layout with internal design in the same format. Each row with imageviews - This is not encouraged by the way.
Design layouts for each and every format of design per row. Inflate each particular row to a list (using custom adapter). Based on position in getView() you can control which row design to be added to list. Inbuilt scroll in ListView, so no problem!
I suggest you to go with number #1 or #3. Using fragments you will have better control.
If you come to know any better idea, please share!
It's StaggeredGridView
You can find an implementation at https://github.com/bulletnoid/StaggeredGridView
It's possible using GridLayout. More details in the link.
http://developer.android.com/reference/android/widget/GridLayout.html
Related
I know it may be weird that I want to succeed.
Let me explain whole in details. Firstly, I want to use two ListView looking in an Activity screen. Just like how Pinterest looks like. (I'm not sure is it true but it's named as heterogeneous gridview.) There is also one thing that I needed to implement: lazy loading. There are about 30 images in my activity, so that's not good to fetch all images at one time. That's why I needed lazy load.
So in first, I pondered on that I how obtain that appearance, I mean heterogeneous gridview. Then decided to add to LinearLayout in a ScrollView. Linears have vertical orientation. With thay approach, I added my new views by using odd-even method in Linear Layouts.
Althought, there weren't any adapter so according to my knowledge, there is no way to controll which items would be displayed. So lazy load is not suitable.
I've also tried two ListView in an Activity, but got some lag and also synchronous scroll problems. On the other hand it has a bad recycling.
So in this scenario, I want to ask is there way to fill LinearLayouts using Adapter? Or what would you recommend to create a heterogeneous gridview but also with lazy load.
If my approaches are wrong, I would not hasitate to change it.
Any clue would be great for me. If there is something unclear, please specify it. I'll explain with more details.
After a lot of research, finally I found a library which have lazy loading and heterogeneous gridview and also not has any scroll or recycling lags/problems.
Maurycy's StaggeredGridView is completely what I'm looking for.
Here is the library and also there is a demo too.
If I get your question right, here is what you need: http://spinlist.autsia.com/
I was wondering how to implement the listview like the android market.
in the right hand panel a listview is divided into the two rows. This is very useful because it saves lot of space and user can look at almost double items in the listview at a time. how can I implement this ? any suggestions?
you can use GridView instead of ListView of two columns..
1. GridView
2. GridViewExample
Sample design :
The Android Market also uses the ViewPager to scroll between the pages. Here is an example on how you could implement it.
There is another question that is related to this one.Check the folling link, it might help you:
How to display a two column ListView in Android?
Modify you *.xml file to get what you want.
Good luck!
If you want to do this using listView, then each item (row) in the list view should consist of two views. You can do this using a relative layout (or linear layout) with two items side by side.
You can also implement this using a gridview having two columns.
Things are simple, I want to make a widget with 4 lines and 4 rows in it, on each cell there would be a click-able image and an action set by the user via the Settings page.
The layout is like this:
What layout element is recommended to be used for this scenario ? Should I use a GridView, TableLayout, more Linearlayouts ? Keep in mind that the spacing between items must be the same. I want to make it as light as possible. So, what layout ?
If I decide to use a GridView do you have any simple tutorial about
this? I can't manage to find a way of accessing the GridView from
AppWidgetProvider and set it's Adapter. Thank you.
LE: It seems that GridView is supported starting from Android 3.0.. please correct me if I'm wrong. In this case the only remaining thing to do is add 16 images and for each image add a onClickListener ? Brrr...
If you use a GridView then half of your work is done for you - The only layout and formatting elements you need to consider are on a Global (GridView) and Item level.
Using a GridView will also give your Scrolling functionality and the ability to change your row/columns count based on your device (4x4 on tablet, perhaps 2x8 on a phone).
Creating an extension of BaseAdapter to attach the Grid's children will also give you the flexibility to check items, multi select and will allow you to quickly modify the implementation in future by adding and removing items at will.
If this is simply a 4x4 grid which will always ALWAYS remain the same independent of device and each "Item" will always be the same, Use a RelativeLayout as it will be the most lightweight and efficient ViewGroup.
I want to have more than one dynamic listview with title in one signle activity.each list item has the image and it's name.i have to do like below image.Please suggest any solution.
Thanks,
you have two options:
i) either partition screen in two parts using weight attribute and use different listviews.
or
ii) you can take a look at good tutorial here for an idea.
one more concept if you find easy is using MergeAdapter
i am quite new to android and i was wondering how i could go about adding a listview with different images and text. What i am trying to achieve is a listview with four rows which have a different Icon? I don't know how to set that up using the xml layout provided. should i build this using different multiple linear layout or is there a better way to go about it?.. All the examples i have seen all seem to be using one particular Icon and no much detail of the xml layout. Any help will be greatly appreciated. Thank you
If you have a fixed number of rows you can just use a LinearLayout and save yourself some headache. If you need to have a dynamic number of rows then you need to make a custom adapter for your list. If you do a Google search, there are a lot of tutorials on how to do that.