Is there any lib that can help me to achieve what CollagePlus jQuery library does?
I have a list of pictures (link and dimensions). Dimensions could be different and i need to arrange all images inside one view like in attached screen.
Update. I have a listView (RecyclerView), each item could have such gridView - so layout_height has to be wrap_content.
I've tried StaggeredGrid - that's not exactly what i want.
Also tried AsymmetricGridView - very buggy.
the support library there's the new RecyclerView that can achieve exactly that, you just have to use the GridLayoutManager and supply a SpanSizeLookup
here are the links for the docs
https://developer.android.com/reference/android/support/v7/widget/RecyclerView.html
https://developer.android.com/reference/android/support/v7/widget/GridLayoutManager.html
https://developer.android.com/reference/android/support/v7/widget/GridLayoutManager.SpanSizeLookup.html
This should help you achieve what you want. It's etsy's staggered grid view. Well supported.
https://github.com/etsy/AndroidStaggeredGrid
Related
I am developing an app in which i need a layout like provided images.
Which layout should i use? and why ?
What is difference between GridView and GridLayout ? why they are in legacy section ? What are alternatives and best practices ?
Following are the layout i need to develop. i can achieve this
layout many ways but i need to know best practices.
I believe I came across the same problem you had. From the google documentation websites above and this answer GridView VS GridLayout in Android Apps, I got a clue.
use GridLayout when you only want to align the position of your child view widgets. In this case, the children should not be scrolled. Grid Layout does not support recycling, which will scrap old child views that are not on the screen and recycle their view holders. You should not have too many child views, otherwise an OMM will occur!!
if it is not case 1, I believe we should use recycler view. When your children items may be in the scale of 10 + or cannot fit on the screen, you'd better use recycler view. GridView is available since API 1. If you try to click the GridView guide link in the GridView reference guide, you will be redirected to Recycler View guide website. In this website, I quote
GridLayoutManager arranges the items in a two-dimensional grid, like the squares on a checkerboard. Using a RecyclerView with GridLayoutManager provides functionality like the older GridView layout.
StaggeredGridLayoutManager arranges the items in a two-dimensional grid, with each column slightly offset from the one before, like the stars in an American flag.
Google also has sample code for recycler view at https://github.com/android/views-widgets-samples
These are the websites that I looked into:
https://developer.android.com/reference/android/widget/GridLayout
https://developer.android.com/reference/android/widget/GridView
https://developer.android.com/guide/topics/ui/layout/recyclerview
https://medium.com/google-developer-experts/android-grid-layout-1faf0df8d6f2
https://stackoverflow.com/a/11307615/10075771
this will help you understand more about gridview and gridlayout. And for my opinion, as what i see in the layout you want to achieve, its best way to use gridview.
I have a problem with the design of the picture. I have tried many ways to do this. I used GridView to make a similar thing. But in GridView rows columns are equal. Please help me to do this. Suggest me some XML to design a layout like this image.
You can use staggered grid. Use RecyclerView with StaggeredGridLayoutManager.
Check this example:
https://inducesmile.com/android/android-staggeredgridlayoutmanager-example-tutorial/
You can Use RecyclerView to make this kind of layout.
https://developer.android.com/training/material/lists-cards.html
By using staggeredgridview You can acheive this layout
How to do a layout like this? I currently use a listActivity and I need the same experience with this kind of layout.
You can use Staggered Grid View library. Also check and Quilt View. This is what you need.
To get this effect, you should create two list views and link the scrolls of both lists.
Define a OnScrollListener on both listviews and when "onScroll()", move programatically the other list. I think if all images are cached you shouldn't have delays.
You can use Staggered Grid View library. But there you need to mention height of each image pragmatically to set height of list view. Else when you scroll to end and come back to top, the alignment of images on top will get disturbed
You have to use GridView
You can refer this or this.
How can I add Grid View to the ListView.I could able to Implement but the problem is Grid View is not Visible its full height. I want to implement just like the Dropbox Photo CustomView which I have attached below. Please guide me in correct Path.
Thanks,
Chaitanya
Using github.com/TonicArtos/StickyGridHeaders library for placing headers in gridview and refer this article http://www.programering.com/a/MjN0ITMwATU.html where is the demo as what are u expecting.
The thing is that you are not supposed to add a scrollable view into another scrollable view. Both ListView and GridView are scrollable, so that just leads to trouble. I suspect that the Dropbox app does not use a GridView, but multiple LinearLayouts, that's at least what I would do. You just can not use an adapter in that case, but need to add the layouts and elements programmatically.
I'd like to make a layout similar to the one used in the current version of Google Plus:
I don't know which layout I must use because :
- I can't use a GridView because it doesn't support spanning row.
- I can't use a GridLayout nor LinearLayout because the number of elements to show is dynamic
- I can't use a ScrollView because I want an AdapterView to re-use child elements
- I can use a ListView with two differents cells types but I can't use the built-in OnItemClickListener.
Do you have better ideas than me?
Thank you very much :)
this post suggested that it uses StaggeredGridView . I personally haven't tried it.
You can very well use RelativeLayout for this.
With a single Relative Layout you should be able to create exactly same layout.
Additionally, your content can be dynamically added to Relative Layout pretty easily (by setting proper LayoutParams to the content to be added).