Does anyone know how you can use ScrollView
in a fragment
using the Tabbed Activity Template
when creating a new activity
. It uses a viewPager
by default, and I've made 3 tabs with 3 different layouts which I can slide through. But every time i try to use the ScrollView
in any one of these tabs the program gets buggy and nothing happens, sometimes i can't even swipe. So, in different words:
My Question: What is the proper way to use scrollview
in a tab(fragment)
when using the default tabbed activity template
with ViewPager
?
UPDATE 1
The thing with NestedScrollView
worked, but now this is the new problem that came along with the solution. The AppBar scrolls along with the other stuff. How can i fix this?
UPDATE 2
It looks like the scrollView
has an effect on this type of AppBar
(Toolbar to be more specific), and i just fixed the problem by adding app:layout_scrollFlags="enterAlwaysCollapsed"
to <android.support.v7.widget.Toolbar/>
, and it's now stationary.
Additional link:
For reasons that might seem unclear to most of us, it is hard for touch events to be differentiated when you want to scroll vs swipe.
To solve this, I used a NestedScrollView instead of the regular ScrollView.
The other option would be to catch the events and override them - obviously more complicated to do but possible.
You can take a look at my recent code on github for an example.
Good luck and please let me know if it works for you!