Android resizable Toolbar accordingly to scroll on Observable ScrollView - android

as you can guess from the title I wanted to reproduce the behavior I have seen in apps like Telegram v2.3.2 (Settings activity).
In this paricular case the Toolbar starts from an initial size and then adjusts its height (and also scales down the views in it) down until it reaches the 'normal' height of a common Toolbar according to the scroll that happens throughout the main content of the activity. How to achieve that?
As i was starting from scratch I've searched the web and found ManuelPeinado's gist which derives from FadingActionBar project, it hosts a View called ObservableScrollView which can monitor for the scroll events. I thought I could resize the toolbar when onScroll is called, but I didn't figure out how to achieve the result.
I also found that Telegram sources are available, which I think it's supercool but they are pretty difficult to read as they are complex, and I can't identify which part of code is responsible for what.
Any advices on how to implement this functionality, or some other resources from the web?
Thanks in advance.

Android-ObservableScrollView is a library which helps build this functionality.
It supports:
ListView
ScrollView
WebView
RecyclerView
GridView

Related

How to make a toolbar expand when pulled down and gets retreat to middle position which is exactly as describe in given video?

the collapsing toolbar must expand to full screen when pulled down and must scroll back to intermediate position when pulled up (even slightly). and it must act normal when scrolled up as toolbar does.
i want to learn making ui like video in link given below
please help what should i learn and do in order to achieve this ui:
https://drive.google.com/open?id=0B14wNBitoI33MUhWM05FYTZ2czQ
You need this CollapsingToolbar
It is available in Google Support Design Repositries
UPDATE:
Check this: Answer By MiguelHincapieC
Library: CustomBottomSheetBehavior

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!

Youtube like tabs implementation

I am trying to implement youtube like tabs.
Is there a way to achieve this with CoordinatorLayout, AppBarLayout and TabLayout ?
I already tried to change AppBarLayout height in onScrollListener in fragment, but it is causing some scroll flickering.
Youtube tabs
Definitely there's a way to do it. That's what AppBarLayout was born to do -- stuff like that.
But if you're trying to change the AppBarLayout height in an onScrollListener in a fragment, you have run far afield from the way those components are supposed to work.
Be forewarned that these components are fragile as heck, just barely do what they are supposed to do, are not well documented and they break easily. Doing something like hammering away at the AppBarLayout height would go far beyond "breaks easily", and venture well into the realm of "that's not really how it's supposed to work at all".
Putting the ListView (or RecyclerView) in a fragment may also go horribly wrong for all kinds of fairly obvious reasons relating lifecycle and order of instantiation of views.
I would suggest starting with a working sample for AppBarLayout, and moving your way forward incrementally from there. If you're using Android Studio, right click on your app folder, and select New/Activity/ScrollingActivity, and work your way from there.
Whether you can drive the AppBarLayout from a ListView or RecyclerView in a fragment or not, I couldn't say. I think you should be able to do that; but I'd suggest that you get a dummy listview working as a direct child of the activity first, and then try migrating it to a fragment afterward.
Expect it to be hard. And expect that you'll have to live with limitations of inflexible implementation. They do what they do. And do not like to do what they don't do.

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.

How to make a scrollable app widget?

As far as I have read in the Internet and official documentation, it isn't possible to make a scrollable app widget. Also all my tries failed. I even tried to subclass TextView to implement my own scroll method, but nothing worked.
Are there any ways to achieve that?
Btw.... there are solutions if you use for example htc sense or home desktop ++, but i want to make it available to other users which don't use this
Are there any ways to achieve that?
Not directly. You can always add buttons to rotate you through various options. But true scrolling is not possible.
HTC provides scrollable app widgets because these are built-in. Only their Launcher can create and display them. Regular app widgets do not support scrolling.
As far as I have observed, app widgets are scrollable, but only in the vertical direction.
For Eg. The calendar widget is a scrollable widget which comes with mostly all android phones.
Only the vertical scrolling is allowed for the fact that horizontal scrollings are required to change the screens in the home page.
It is said only 2 gestures are allowed for a widget,
1.Touch
2.Vertical scrolling.
Source : Developer's Page
Now you can make a scrollable widget, but you'll have the problems with images within it. Workaround is described here.

Categories

Resources