How to Add ViewPager Indicator Headings Like Google+ App - android

My goal is to create a screen similar in function to the Stream page in the Google+ app (picture below for those unfamiliar). For the paging, I am using a custom ViewGroup so that it has smooth transitions that "follow your finger" rather than just snapping to the destination after the fling gesture has been made.
Question
Currently, I am going the route of using some TranslateAnimations to move the headings ("Nearby," "All circles," and "Incoming" in the screenshot) once a new page has been selected. This creates a couple of problems: the center heading doesn't follow the user's finger (as you can see the "All circles" heading does in the screenshot), and if the user begins on a page other than the middle one, I have not found an easy way to offset all of the animations temporarily without running them first since the animations do not move the actual views.
Am I going about this the correct way, or is there a much simpler way of accomplishing this that I am overlooking?
Thanks

After hours of searching and a little luck with search terms, I came across A Google+ like ViewPager page indicator.
I also came across Android ViewPager Indicator, created by the same developer who wrote ActionBarSherlock. Has a ton of examples, and is pretty easy to integrate with the FragmentPagerAdapter.

Google has published his own solution in support library.
Check:
PagerTitleStrip,
PagerTabStrip

Have just used ViewPagerIndicator solution and its very nice and smooth. You can demo the effect by looking at the demo from the Android Market here

I am not 100% sure, but I think it uses the new ViewPager.
Maybe you should look at the API 4+ Support Demos:
FragmentStatePagerSupport.java
FragmentPagerSupport.java

Related

Nativescript Vertical Screen Slide / ViewPager

What is the easiest way to implement a screen slide in Nativescript like shown in Android Viewpager , but in a vertical direction ? Another example of this functionality would be the rss reader feedly where you can change rss feeds by swiping up/down.
The page should allow vertical scrolling to the top/bottom and then transition after a certain treshold.
I already encountered nativescript-slides, which can only do horizontally sliding.
So is there a "nativescript" way or do i have to implement it as native android/ios feature (for example by this) ? In either case a sample on how to integrate it in nativescript would be great.
Update
Recorded an example:
taken from this Repo with Android native code. The outstanding PR made changes to offer vertical scrolling in the list. But the repo seems to be outdated and a bit buggy.
I can provide more info later but there's a new plugin implementing the native controls for android and iOS for slides/carousel her https://github.com/alexrainman/nativescript-carousel-view and vertical swiping is on his radar, I think he might even be close to completing that.
To give an answer for anybody interested in above nested scrolling animation:
For Android I had to implement the native ReyclerView in Nativescript in favor of the NS buildin ListView. It is an optimized view structure which among other things allows nested (vertical) scrolling and can be used as replacement for an ordinary list.
Together with https://github.com/alexrainman/nativescript-carousel-view works like a charm!
Anyone that ends up here still looking for ways to achieve this.
I spent a lot of time trying to figure out a way to achieve this and tried to find ready plugins for this. Also tried to use the plugin from Alexrainman but eventually gave up since the plugin was not up to date with the current nativescript-version.
My solution:
I used radListView as a basis for this implementation and leveraged the methods and events on the radListView.
By using scrolled-event I gathered data for the use of the scrolling feature: scroll Speed and scroll direction. (These might be also taken from the event data, but since I did not find the event details from the Nativescript-documentation I gave up trying to guess where to find this data on the event-model).
Then I also saved the fixed height of one item on my list (The height I fixed to screenHeight-200).
With all this info, I managed to hook the event "ScrollDragEnded" and add logic that makes my list behave like a vertical slider. Moving on the list by method "scrollToIndex" and figuring out which index to scroll and when by leveraging all the data mentioned above.
This is the way I managed to make a pretty good vertical slide.
Good luck!

Android implementation of tutorial screen

I'm planning to implement tutorial screen for Android app.
My plan is that tutorial screen looks like:
There are several screens and you can swipe between than. Every view has custom design. There are dots which represents every screen, and show what page are you watching now. I need good-looking transition with adequate animations.
This screen will be full screen activity.
I have found several Image Galery, but I don't want to slide between images, I need to slide between views.
I do not need exactly code for this. I need instruction in which way this can be done, and what elements I need to use in order to achieve targeted design.
Thanks in advance.
You'll want to use ViewPager in conjunction with Fragments, the instructions are on Android developer's website.

Create UI like Chrome for Android

I want to implement this behaviour [https://github.com/gleue/TGLStackedViewController] in an app that I am trying to make.
The closest thing/the effect that I want to achieve is how the Google Chrome browser behaves.
Tile/card interface
Be able to access a form of navigation (access other tabs) when user pulls down the address bar
Be able to re-arrange the tabs in any order the user wishes
Photo taken from this Android Layout : How to implement a UI similar to deck of cards? SO question
Is there anyone out there who has tried to implement this kind of behavior? Do you guys know any libraries that can help achieve this effect? It would be very helpful! Thank you
systemUI/Recents package, as mentioned by Andrei, can be your starting point. It adds a little more to the flat rendition of chrome tabs.
I have been meaning to refactor systemUI/Recents package ever since I got the L update. I finally got to it.
A sample project is hosted at: Link
Even though the viewgroup recycles, it updates the progress map (child properties) for all children on each scroll step. This will lead to lags with large data sets. For a few hundred, it should be fine.
The sample project uses Picasso for loading and caching images from LoremPixel. Since these are random images & may repeat, you can verify that they are bound correctly by looking at bottom left of the image.
If you feel like looking through the AOSP code, the functionality you are looking for is actually open-source and you can find it in Android 5.0 in the recent apps screen. This is the code you want to look at on github.
The view you want to extract from AOSP is the RecentsView. This would be the best approach.
You could also consider extending StackView and overriding onLayout() so you get the children to lineup.
One other option is to extend ListView, override drawChild or layout methots and try to shift the views according to their position. You can find some inspiration here and here

How to implement swipe pages [duplicate]

I'd like to make a view in my Android app that flips between multiple views on a swipe/fling. I'd like it to behave more or less like the Android Launcher behaves when flipping between views. In particular,
It should flip views on swipe.
Generally a swipe will flip between one view and the next. It should not fling across all of the views.
If you swipe slowly, you should see the views dragging as you're swiping, eg. the way the Launcher does it.
I tried using a ViewFlipper with a GestureOverlayView as per Romain Guy's blog post here, but there's no indicator to the user as they're swiping. This makes discoverability difficult, which is presumably why Launcher does it the way they do.
I tried using a Gallery object, but when I swipe from left to right, there's a certain amount of momentum that flings the users through all the views rather than just taking them to the next view.
Is there a good way to accomplish what I'm trying to do?
I know this is an old question but ViewPager is created for this exact same purpose. ViewPager is part of android compatibility package and more can be found at http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html
Take a look at HorizontalPager. It's actually based on RealViewSwitcher, which in turn is based on the Android homescreen's code, and supports snap-to paging with drag feedback, as well as nested vertically-scrolling subviews. Gesture support for fast swipes isn't all it should be, but this may get you part of the way there (and I'd welcome contributions back).
EDIT: As of 2012 you're much better off using Google's ViewPager - it's in the compat library.
Check out SwipeView within this project https://github.com/fry15/uk.co.jasonfry.android.tools It does exactly what you want it to do and is super simple to implement.
#CommonsGuy extended ViewFlipper to do it.
https://github.com/commonsguy/cwac-viewswiper
Ihaven't used this one yet so im not sure if it moves with your finger like the launcher if not your going to have to make an OnTochListener to do it for you in me.ACTION_MOVE you will update the view to change its position. I'll post some sample code when I get home if you don't get another answer.

ViewPager indicator like Google+ App, or Google Doc App

I'm trying to implement the title indicator like the one found in Google+ Android App; I've come across two implementation, one by Jake Wharton and the other by Mark Gjoel.
What I want is to be able to swipe on the indicator to switch between the different views, and swipe on viewpager to go back/forth on image results that I load from the SD card.
I've implemented the layout for the indicator, but I don't know how to "move it" (follow the users finger within the indicator layout) as the user swipes on it. Also, I don't know, how to move the viewpager at the same time with the indicator, so the interaction looks natural.
If you have Google+ App, try to do a swipe on the indicator in the stream section, and you will know what I am talking about.
Any tips would be greatly appreciated.
Following links may help you.
GreenDroid
AndroViews code
AndroViews video
ADW launcher
PageScroller
Look at the listeners in ViewPager, copy the same action to your listeners only the movement part, not everything what it does. Now, when you detect user swiping on your indicator, implement or call the function that does the swipe on the ViewPager , so that they move together.
HTH.
Try the implementation by chainsdd for Superuser app:
https://github.com/ChainsDD/Superuser/blob/master-dev/src/com/noshufou/android/su/widget/PagerHeader.java

Categories

Resources