Open YKW93 opened 5 years ago
Since it has scroll change listener, I should have no trouble to support it. However, I can't offer you a deadline. Besides, you should probably be using RecyclerView
, anyway. Please take a look at this.
thanks. I solved the problem through scroll change listener.
@YKW93 how you solved ? can you put some code ?
@JavaYank hi I couldn’t get the result through WaterFall-toolbar library so I created the custom listener and used that instead. I will add the code I used below for your reference. Please let me know if there is a better way to do it. Thank you.
public class ShowingShadowListener implements View.OnScrollChangeListener {
private AppBarLayout appBarLayout;
public ShowingShadowListener(AppBarLayout appBarLayout, NestedScrollView nestedScrollView) {
this.appBarLayout = appBarLayout;
nestedScrollView.setOnScrollChangeListener(this);
}
public ShowingShadowListener(AppBarLayout appBarLayout, RecyclerView recyclerView) {
this.appBarLayout = appBarLayout;
recyclerView.setOnScrollChangeListener(this);
}
public ShowingShadowListener(AppBarLayout appBarLayout, ScrollView scrollView) {
this.appBarLayout = appBarLayout;
scrollView.setOnScrollChangeListener(this);
}
public ShowingShadowListener(AppBarLayout appBarLayout, WebView webView) {
this.appBarLayout = appBarLayout;
webView.setOnScrollChangeListener(this);
}
@Override
public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
if (v.canScrollVertically(-1)) {
appBarLayout.setElevation(appBarLayout.getContext().getResources().getDimensionPixelSize(R.dimen.appbar_elevation_4dp));
}
else {
appBarLayout.setElevation(0f);
}
}
}
@hugocbpassos can you help with solving the problem?
@JavaYank The implementation of @YKW93 doesn't work for you?
@hugocbpassos fits, I just need to refine the smoothness a little more. If your project was more universal, then it would be cool 🙂
@JavaYank You'll handle that as soon as I have some free time :)
I'm using the Nestedscrollview. How can I apply that library?