RecyclerView with Horizontal GridLayoutManager and PageIndicator - android

I am relatively new to android and stuck on this particular implementation.
How do i implement a View(RecyclerView) with Horizontal GridLayoutManager(3*5) along with PageIndicator so basically 1st page would show 15 images, swiping left would show another 15(PageIndicator would change color) and so on.
Thanks in advance!!

you used viewpagerand set recycler view in viewpager or gridview. viewpager to handle swipe and easy. and you give it pageindictor in viewpager it's implement is easy.
you use recycler view in you give left is hard and you do use pagination so it's implemention is hard

It's frustrating when you are been downvoted, and i understand that, hence i tried to implement this myself and the implementation details can be found here
Adjust Items inside recycler view + orientation changes.

Related

How can i swipe through recyclerview items in a manner similar to a viewpager?

I've been trying to implement a recyclerView to function similar to a ViewPager by displaying one item at a time. I looked at https://github.com/lsjwzh/RecyclerViewPager and found it useful. I basically want to implement a vertical ViewPager using recyclerView wherein each item overlaps over the other during transitions. Should i be looking at inter-item animations? And if so, I would appreciate any help that i could get.
Or should I just stick to a ViewPager? (My apprehensions about ViewPager are that it may be slower than a recyclerView)
You can try this project I did for Udacity Android Nanodegree.
This holds a similar functionallity:
https://github.com/sprengerst/udacity_nanodegree_project_5
There, a Viewerpager is populated by Fragments which are then populated by a Loader.

Which View/Widget can be used to display images on the screen one at a time by swiping horizontally?

I have a list view in which I want each list item will contain images. But the images will be displayed one at a time. SO, at a time for every list item only one image will be displayed. To view other images in the list item,one has to swipe horizontally. Is there any inbuilt widget that handles this in android?
EDIT1
My List item not only has Image but it also contains other views like textview, seekbar etc. So each list item will contain Image, textview, seekbar etc but the majority of the space will be occupied by the Image. Now, for each list item, when the image is swiped horizontally, another image has to be downloaded from a ulr and displayed.
EDIT2
I did a bit of research on ViewPager but many references like the answers here and this blog seem to suggest that using ViewPager inside a listview is not a good idea. Why is that? If it is not a good idea, what is a good alternative?
This problem can be solved by using ViewPager.
Link: http://developer.android.com/training/animation/screen-slide.html
ViewPager(for swiping between views) + UniversalImageLoader(for loading images from URLs, with caching etc)
If it is not, what is a good alternative?
I think you should use RecyclerView with LinearLayoutManager.HORIZONTAL. All things like recycling the views, view holder design pattern can be done easily with it and it is a new widget that google introduced and you can use it instead of ListView + ViewPager. because as you suggested it is not recommended to use viewpager inside listview. Although you can use horizontalScrollView but it dose not recycle the view. Other third party library like this exist but I recommend you use RecyclerView with LinearLayoutManager.HORIZONTAL because it is from google and it is normally tested more than people library. And another thing is you can use other layout manager like GridLayoutManager or having for example 3 rows that swiping horizontally or other good effects like adding animation and .... that google provided with RecyclerView.
For downloading the images you can use Picasso,Volley, Universal Image Loader or a lot of other libraries that exist.
Happy Coding :-)
Not sure I'm following you, but rather than a ListView wouldn't it be simpler to use ViewPager with simple Fragment that wraps a single image at a time. That way you get horizontal swiping "for free".
Do you just want swipe to change images? Or do you want the images to scroll as you swipe? For the former, you can just use a GestureDetector. For the latter you would probably use a ViewPager. See http://developer.android.com/training/animation/screen-slide.html
I have achieved the same functionality by using ViewPager, you can either put the SeekBar and TextView in the Fragment class off which you are gonna make multiple instances for each item and add to the pageradapter,
You can also add the TextView and SeekBar above the ViewPager Layout in your main fragment layout file and change the text and data on seekbar on viewpager's on item change listener, this looks more neat and this is the approach i've used

Horizontal Carousel or ScrollView with text over image

I'm trying to figure out the best approach to design a horizontal scrollview from android >= 2.1 with some text over the image that when scroll if end is reached it starts showing the first items again hence carousel behavior.
You can continue scrolling horizontally, forever, and the first item shows up again when the end is reached, for example when scrolling swiping to the left. It can be a view pager with an adapter, a carousel but not horizontal scrollview as it does not support some android device.
Any suggestions would be greatly appreciated.
Why not use a ViewPager? As it is available in the Support Library. I would insist to use ViewPager instead of HorizontalScrollView or Gallery. You can check an example for ViewPager from my github.
UPDATE
To show multiple views inside a Fragment you can use getPageWidth(). Check here for reference.
For future people looking for this, here's an excellent library that fit my needs for a similar problem!
https://github.com/sparrow007/CarouselRecyclerview

How do I implement such a layout?

Photos in this layout can be swiped left and right, and swipe should be 'intelligent', like switching between photos and NOT like just horizontal scrolling of photos.
2 implementations that come to my mind:
HorizontalScrollView (but swiping is dumb)
ViewPager (but there is no way to see adjacent photos)
So, basicly I need a ViewPager for photos that can show adjacent photos.
Is there a robust solution for this?
For cool swiping action viewpager is the best. And you won't have problems with memory. BUT I have no idea how to make view pager part of listview.
If you have final number of items you can use Android Gallery widget which is deprecated since api 16 but does exactly what you need, the main problem is that it cant reuse gallery items inside the adapter.
You also can try this:
Horizontal list view
I have used TwoWayView to implement my layout.
It's better than HorizontalView, cause it re-uses views (like ListView).

How do I add a ViewPager as the top item in my ListView

I have a vanilla "News" app, where the main page is a ListView that scrolls vertically with a list of articles (thumbnail, title..etc). This works just fine, but now I want to add a horizontal article/photo rotator as the top item in that list. I don't really care if it's technically in the list or not, but it should scroll up/off the screen when the list is dragged...etc. I assume(d) it should be in the list, but am quite new to Android and don't know if there's a better solution.
After an entire day of searching around, I'm still empty-handed - don't know how to add it or even if it's the right method. I'm using a ViewPager for my gallery view (when they click a photo), and that seems to be working fine...but that's the entire view... and this one already has an adapter that populates the listView... I hope I'm just over-complicating something.
TLDR:
1) Can I add a ViewPager as top item in a ListView?
2) How would one go about doing it?
3) Is there a better solution?
Note: android:minSdkVersion="8" android:targetSdkVersion="15"
You can use addHeaderView() from the ListView API to set a header. It can be any View, so also a ViewPager. I think you'll have to add it programmatically. Set the height of it correctly though.
i'm not sure i understand your question. ViewPager is a view like any other, so in your ListView's adapter's getView() method, return a view that contains a ViewPager.
ViewPager is a topic in itself, so if your problem is that you don't understand ViewPager, read these links,
http://developer.android.com/reference/android/support/v4/view/ViewPager.html
http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html
if you are using API level 8, you should use the ViewPager and friends from the compatibility package.
that all being said, i wonder if you will have trouble putting a scrollable view inside a scrollable view. i know ViewPager contains code to pass off any gestures to child views if it decides it cannot handle them. i can't say if ListView has the same smarts.

Categories

Resources