hcbpassos / waterfall-toolbar

MIT License
288 stars 22 forks source link

NestedScrollView support #8

Open YKW93 opened 5 years ago

YKW93 commented 5 years ago

I'm using the Nestedscrollview. How can I apply that library?

ghost commented 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.

YKW93 commented 5 years ago

thanks. I solved the problem through scroll change listener.

JavaYank commented 4 years ago

@YKW93 how you solved ? can you put some code ?

YKW93 commented 4 years ago

@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);
        }
    }
}
JavaYank commented 4 years ago

@hugocbpassos can you help with solving the problem?

ghost commented 4 years ago

@JavaYank The implementation of @YKW93 doesn't work for you?

JavaYank commented 4 years ago

@hugocbpassos fits, I just need to refine the smoothness a little more. If your project was more universal, then it would be cool 🙂

ghost commented 4 years ago

@JavaYank You'll handle that as soon as I have some free time :)