Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HeaderView Issue #49

Closed
aamirmsw opened this issue Apr 5, 2017 · 5 comments
Closed

HeaderView Issue #49

aamirmsw opened this issue Apr 5, 2017 · 5 comments

Comments

@aamirmsw
Copy link

aamirmsw commented Apr 5, 2017

@noties : Header view is going inside the toolbar , i need to make header view below the toolbar with size variation as on scroll up size should get reduce and on scroll down size should get increase.
review_screen

@noties
Copy link
Owner

noties commented Apr 6, 2017

Hey @aamirmsw

As I see the scroll distance is more or less equals to the Toolbar height, so I assume that you have autoMaxScroll parameter set to true and Toolbar is the first view inside ScrollableLayout in your XML layout. Can you confirm?

@aamirmsw
Copy link
Author

aamirmsw commented Apr 6, 2017

See all ,Here is the both the file main activity and fragment file i have uploaded ,
i am using framelayout inside main activity and adding fragment in this framelayout which contains "ru.noties.scrollable.ScrollableLayout" as a parent layout in fragment. The 'scrollable_maxScroll' size is 100dp ,more Toolbar is not firstview inside the ScrollableLayout.

Here is a xml fragment file
fragment_rewards.txt

Here is main activity xml file

activity_main.txt

@noties
Copy link
Owner

noties commented Apr 6, 2017

Well, I see that you have specified scrollable_maxScroll="100dp" it means that ScrollableLayout will scroll exactly 100dp. If you want to completely hide header, you must provide it's exact size via maxScroll attribute. If you not know the size of your header beforehand, you can use scrollable_autoMaxScroll="true" attribute that will automatically set scroll distance as the height of the first view

@aamirmsw
Copy link
Author

aamirmsw commented Apr 7, 2017

I don't want to hide complete header ,just i want to scroll half of the header and the size of view inside the header will increase and decrease accordingly scroll up/scroll down ,but here what happens , when i set scrollable_maxScroll="100dp" it scrolls half of header but header goes inside of the toolbar.

@noties
Copy link
Owner

noties commented Apr 7, 2017

Well, the header is not going inside the toolbar, it just scrolls. If you need custom handling of a scroll state, then you have to implement your logic in Java code, for example:

scrollableLayout.addOnScrollChangedListener(new OnScrollChangedListener() {
    @Override
    public void onScrollChanged(int y, int oldY, int maxY) {

        // `ratio` of current scroll state (from 0.0 to 1.0)
        // 0.0 - means fully expanded
        // 1.0 - means fully collapsed
        final float ratio = (float) y / maxY;

        // this will scale down the header when `collapsed` (but no less than half of original height)
        headerContent.setScaleX(Math.max(.5F, ratio));
        headerContent.setScaleY(Math.max(.5F, ratio));
    }
});

Basically you can do anything with your header there

@noties noties closed this as completed Jul 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants