Comments (12)
Hi!
If I got you right you mean something like that:
If it looks like your issue, than you somehow misused CanScrollVerticallyDelegate
.
In this gif It always returns false, which is equal to setting ScrollableLayout.setCanScrollVerticallyDeletegate
to NULL or never setting it at all
from scrollable.
Thanks so much.
Please how do I reduce the slidedown speed of the header? I want it to slide down with the same speed as the list fling speed.
from scrollable.
Set scroll friction via code scrollableLayout.setFriction(float friction)
or via xml attribute app:scrollable_friction="0.075"
.
Try playing with values in the sample application, it has seek bar with current scroll friction indication. For my own taste something between 0.05 & 0.075 feels smooth
from scrollable.
Thanks.
from scrollable.
@noties somehow recyclerView is always null in canScrollVertically
method in my Fragment. Do you have any idea why this might be the case?
from scrollable.
@squeeish Well, it might be two things: first check if you have RecyclerView in your layout file, second check the id of the RecyclerView (most likely you miss typed it)
from scrollable.
@noties it's definitely in my layout file and the id is correct as I'm setting layout managers and adapters to it. I've 4 tabs in a ViewPager
with Android Design Support Library's TabLayout
as the tab headers. The header is a RelativeLayout
.
When I debug, I can see that the CanScrollVertically
chain is there (delegate, adapter, fragment) but in all 4 fragments' CanScrollVertically
method, the recyclerview variable is always null.
from scrollable.
Ok I've solved it. Turns out it was my FragmentPagerAdapter returning new instances of the fragments in getItem
. 😄
from scrollable.
@noties Could you help me out?
- Go to developer options and check "Do not keep activities".
- Start the sample app and click "Inside Fragment".
- Scroll up and down. The header only shows when the top of the list is reached.
- Press the home button, then open the sample app again.
- Scroll up and down.
CanScrollVerticallyDelegate
seems to always return false this time.
Do you have any idea why this might be the case? This behaviour is not seen in MainActivity
. If you are in debug mode, canScrollVertically
method in RecyclerViewFragment
thinks that mRecyclerView
is null, which isn't supposed to be the case.
EDIT: Fixed. mRecyclerView
has to be static. Same for mListView
in ListViewFragment
.
from scrollable.
Hi! Nice catch!
It happens because we pass to the ViewPagerAdapter
newly created fragments, but the previous ones are still attached to the FragmentManager
. Thus, our newly created fragments won't be added, won't o through onCreateView()
and that's why they will always return false
from canScrollVertically
method. So, to work around this issue, we must do something like this:
private List<BaseFragment> fragments() {
final FragmentManager manager = getChildFragmentManager();
final BaseFragment list;
{
final Fragment fragment = manager.findFragmentByTag(ListViewFragment.TAG);
if (fragment == null) {
list = ListViewFragment.newInstance(0x80FF0000);
} else {
list = (ListViewFragment) fragment;
}
}
final BaseFragment recycler;
{
final Fragment fragment = manager.findFragmentByTag(RecyclerViewFragment.TAG);
if (fragment == null) {
recycler = RecyclerViewFragment.newInstance(0x8000FF00);
} else {
recycler = (RecyclerViewFragment) fragment;
}
}
return Arrays.asList(list, recycler);
}
And then:
final ViewPagerAdapter adapter = new ViewPagerAdapter(
getChildFragmentManager(),
getResources(),
fragments()
);
This solution might work if you have not much fragments. Otherwise it's better to create some kind of helper.
from scrollable.
I will update sample
with the next library release
from scrollable.
@noties Thanks! I knew it was something to do with ViewPagerAdapter
but for the life of me I couldn't figure out why. Your explanation is great, thanks! Looking forward to the next library release.
from scrollable.
Related Issues (20)
- View Pager not taking the complete height even on using "match parent" HOT 1
- Not able to get all library views HOT 1
- HeaderView Issue HOT 5
- when Scrolling the page,the headerview can scroll also HOT 1
- What should I do if there are ups and drop refresh ui in viewpager? HOT 1
- dependencies problem HOT 1
- nested two page bug HOT 1
- How to use FragmentStatePager Adapter HOT 1
- ScrollHeader is not smoothly HOT 2
- dude HOT 2
- Change viewpager item size dynamically with listview scroll HOT 5
- Header reappears on top when returning to fragment that has been scrolled down. HOT 8
- Long press slide up RecycleView item before headview scoll up HOT 2
- Scrollable tab scrolls under title bar HOT 1
- add RecyclerView on the head, slide very slowly, there is inertia slow sliding HOT 1
- bottom part of the fragment in the viewpager is clipped or cut of how to fix this HOT 6
- when topView height is changed , tabLayout below will be covered HOT 5
- not use SwipeBackLayoutTouTiao HOT 4
- Cannot collapsed header view programmatically HOT 2
- scrollable scrollview in fragment not scrolled
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scrollable.