ksoichiro / Android-ObservableScrollView

Android library to observe scroll events on scrollable views.
http://ksoichiro.github.io/Android-ObservableScrollView/
Apache License 2.0
9.65k stars 2.06k forks source link

Scrolls when changing tabs/fragment #272

Open YJArc opened 7 years ago

YJArc commented 7 years ago

I'm using a FragmentTabHost and the ObservableScrollView to show a header with parallax image. Anyways I notice that whenever I change tabs the ScrollView scrolls down the height of the image. It shouldn't even call scrollTo on tab changes. I need it to not scroll when I change tabs so I can save the proper scroll position for the header so when the user comes back it looks exactly as they left it.

Anyways here is the Log at com.github.ksoichiro.android.observablescrollview.ObservableScrollView.onScrollChanged(ObservableScrollView.java:81) at android.view.View.scrollTo(View.java:13358) at android.widget.ScrollView.scrollTo(ScrollView.java:1659) at android.view.View.scrollBy(View.java:13373) at android.widget.ScrollView.scrollToChild(ScrollView.java:1365) at android.widget.ScrollView.requestChildFocus(ScrollView.java:1459) at android.view.ViewGroup.requestChildFocus(ViewGroup.java:741) at android.view.View.handleFocusGainInternal(View.java:5958) at android.view.ViewGroup.handleFocusGainInternal(ViewGroup.java:717) at android.view.View.requestFocusNoSearch(View.java:9130) at android.view.View.requestFocus(View.java:9109) at android.view.ViewGroup.requestFocus(ViewGroup.java:2835) at android.widget.ScrollView.onRequestFocusInDescendants(ScrollView.java:1500) at android.view.ViewGroup.requestFocus(ViewGroup.java:2834) at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2875) at android.view.ViewGroup.requestFocus(ViewGroup.java:2831) at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2875) at android.view.ViewGroup.requestFocus(ViewGroup.java:2831) at android.view.View.requestFocus(View.java:9076) at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:160) at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:532) at android.view.View.performClick(View.java:5637) at android.view.View$PerformClick.run(View.java:22429) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

EDIT: resorted to using a Viewpager + TabLayout to fix the scoll when switching tabs