Vertical 'Gridview with pages' or 'Viewpager' - android

What I functionally need is a Vertical ViewPager with GridView.
So every page of the ViewPager should have a GridView, but the ViewPager is horizontal.
So there are two possibilities:
Rotate the ViewPager with GridViews
Create a GridView that shows the items in pages
The GridView should show 0-20 when the user scrolls 20-40 etc etc.
Does anyone have a solution for this?
I have checked this link, but I cannot use it cause of legal reasons.

Sounds like what you really need is a vertical ViewPager. Although Android only provides a horizontal one, there's nothing that prevents you from implementing it yourself. Get the ViewPager source code and modify it to detect swipes up/down instead of left/right. The source is distributed under Apache 2.0 license, therefore you have full rights to create derivative works without having to distribute the source of it.
There will be very few places to change, specifically, methods related to computing the swipe direction/slope (up/down instead of left/right) and methods related to layout computation (using height instead of width and layout pages below each other).

Related

Vertical Stacked Views

I'm struggling for the past 2 days to find/implement an working solution for my UI requirements for an on boarding flow. This is how the UI should look like:
These pages should be scrollable vertically only.
As you can see, the pages should be stacked on top of each other. The current page (the top one) should also resize if not the first one so that the user can see the top edges of the already swiped up pages.
Beside the arrangement of the pages, when the user swipes an page up or down, there should also be an page transition, something similar to DepthPageTransformer, or at least to easily support changes for these transitions.
Until now I've tried:
Custom vertical ViewPager
Custom ScrollView with custom listener and one-by-one item scroll
Flippable StackView (and multiple other implementations of StackView)
But I've failed to achieve the desired result using any of these approaches.
The flow is similar to the linkedin flippable stackview, with the difference that my requirements are for an vertical widget and with some small minor adjustments which can be adjusted afterwards.
Can someone please help me with this or at least guide me into the correct direction?
Thank you.

ViewPager/ScrollView with multiple view/fragments of different sizes

I am looking for an viewpager or scrollview implementation or guidance on how to construct one that mimics that of the Circa News application, shown below.
The ViewPager or ScrollView implementation needs to be able to handle views or fragments(either, not or) of different sizes. Allowing for any size, smaller than full screen and larger also. The focus would be on the top most(top aligned) view/fragment. The scrollbar indicator on the right side is not a requirement.
So far i've found Mark Murphy's analysis on the basic problem, but all of the results don't fit the situation exactly. Link
I ended up finding this answer while looking for something else, but it partly works for the question i posed with a few caveats.
Parchment is a "Horizontal/Vertical ListView, GridView, ViewPager, and GridPatternView". The key part is the ViewPager, but bad part is its not its a listview and does not support fragments as a normal ViewPager would. But you can achieve the same result.
You use Parchment like any other ListView, the key is in the configuration(which i believe can only be done via xml).
<mobi.parchment.widget.adapterview.listview.ListView
android:id="#+id/verticalviewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
parchment:orientation="vertical"
parchment:isViewPager="true"
parchment:snapToPosition="true"
parchment:snapPosition="start" />
The key is "isViewPager", "snapToPosition" and "snapPosition". This enables the list act like a ViewPager. Only difference is the views are from an Adapter's getView() instead of a fragment.

What's the difference between HorizontalScrollView & ViewPager?

I'm new programming in Android and i have many doubts about what type of classes can i use in my first app.
I want to do a level menu like cut the rope or angry birds. Only a title and a slider menu.
I think that can do with the two classes, but I'm not sure which is better, can you tell me the difference and which is better to use?
Many thanks.
ViewPager allows you to flip between pages of data (between views). You supply an adapter to generate the pages that the view shows.
But HorizontalScrollView is a container for other views that you can scrolled through, allowing it to be larger than the physical display.
I would go with horizontal scroll view.
EDIT : See FoamyGuy's answer in Angry Birds like scrolling menu where he exactly explains how to achieve such effect.

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).

View Flipping in Android using same activity

I am new to android therefore I got a little bit lost with all those ViewFlipper, ViewSwitcher, ViewAnimator and ViewPager. Moreover, I am not sure what's happening under the hood.
Basically I have an activity which shows some data. With swipe (or button, doesnt matter) I would like to scroll the view and get to another page (as seen in the picture below).
Is it possible to implement something like that without changing to another activity?
I am a little bit confused regarding views and access to the design elements. How those pages are located each to another? e.g. If I am currently seeing Page1, can I modify content of Page3? Or plainly saying, are all page views loaded all together? As if I set setContentView(R.layout.xlayout); then I can access only xlayout elements.
But if I use same activity, then I have a thread there which updates a counter on Page1, if I change view to Page 2, the counter will not find Page1 Counter TextView and will complain.
As I Understand Android 4.0 has ViewPager which is similar to the seen in the picture. I am using GB. Should I use support library or can I just go around and implement something similar without importing any libraries?
(Sorry, my description is a little bit messy)
Yes, you can use ViewSwitcher, ViewFlipper and ImageSwitcher depending on your requirements.
ViewSwitcher may have two childs at max. And these child might be a View or an object of subclass of view.
ViewFlipper: May have as many childs you want. and these child might be a View or an object of subclass of view.
ImageSwitcher might be used to switch images over.
By using view flipper you can display one item at a time, and adding a gesture overlay, you can apply sliding effect. To apply View Flipper, you need to add all the views to ViewFlipper, and showNext and showPrevious methods are used to show next and previous child.
You need to use a ViewPager to have the same behaviour as in Google Play.
it only available on recent version of Android, but you can use the Compatibility Package to make it available for older version.
With a ViewFlipper you can't "scroll" between two pages.

Categories

Resources