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

How can i add support to ViewPager? #23

Closed
d-txy opened this issue Dec 11, 2013 · 17 comments
Closed

How can i add support to ViewPager? #23

d-txy opened this issue Dec 11, 2013 · 17 comments

Comments

@d-txy
Copy link

d-txy commented Dec 11, 2013

ViewPager in contentLayout is can't sliding

@ManuelPeinado
Copy link
Owner

Some other people have already requested this functionality so it's high on my todo list. I'll give it a try over the next few days, please stay tuned.

@hugosoares
Copy link

Great lib, but really misses support for ViewPager.
I tried your example that uses fragments but it is re-recreating FadingActionBarHelper on every onAttach event of the framents being paged by the Pager. This produces an odd behaviour in wich the second page changes the alpha of the action bar but the first does not (remains transparent while scrolling).
Let me know if you need screenshots to ilustrate the issue.

It would be cool to somehow listen to the "horizontal paging scroll" and set the alpha of the action bar according to the current vertical scrolling state of the next page.

By the way I am using JakeWharton / Android-ViewPagerIndicator together with Fading Action Bar.

@ManuelPeinado
Copy link
Owner

Hi. I've been considering this and I can't think of a solution that does not involve major changes to the library, so I'm going to leave it aside for the time being.

@MrBrightside29
Copy link

What a pitty... because the lib is awesome. I was expecting to use it with a viewpager too.

@ghost
Copy link

ghost commented Feb 3, 2014

You can use this with ViewPager!

you just have to set a contentoverlaylayout for your viewpager and everything works fine!

@MrBrightside29
Copy link

Really?? I'll give it a try as soon as I can. Thank you.

@MrBrightside29
Copy link

I've tried and I cannot slide the viewpager setting it as header.

@musclorpage
Copy link

What about initActionBar when the framgent becomes visible :

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (isVisibleToUser) {
            mFadingHelper.initActionBar(getActivity());
        }
    }

Simce to work for me...

@ghost
Copy link

ghost commented Feb 5, 2014

use headerOverlayLayout.....
then everything works just fine...

@ja1984
Copy link

ja1984 commented Feb 22, 2014

@FabianHippmann Could you maybe explain a bit better how to do this? I'm not able to get this to work with a viewpager. But my fragments in my viewpager only gets empty and I´m not able to swipe them to the side or swipe up to hide the imageview.

This is what I want my layout to look like

exmple

Thank you in advance!

@kyleparker
Copy link

@ja1984 were you able to get this working? I'm in a similar position and want to be able to use a ViewPager in the content region (not the header, as some other posts have discussed).

Thanks!

@ja1984
Copy link

ja1984 commented Apr 15, 2014

@kyleparker unfortunately no i was talking to someone (much better coder than me) that sort of had something working. I will try to see if he got it working good :)

@CoffeeCode
Copy link

@ja1984 and @kyleparker
look at this question on Stack Overflow it seems to answer this issue.

http://stackoverflow.com/questions/21445296/scrolling-effect-with-multiple-viewpagers

@animaonline
Copy link

@ja1984 @kyleparker Hi, I'm dealing with the same problem as you, were you able to figure anything out?

@kyleparker
Copy link

I wasn't able to get it working so I changed my design layout... Just
didn't want to play well together.
On May 30, 2014 5:13 AM, "Roman Alifanov" [email protected] wrote:

@ja1984 https://github.com/ja1984 @kyleparker
https://github.com/kyleparker Hi, I'm dealing with the same problem as
you, were you able to figure anything out?


Reply to this email directly or view it on GitHub
#23 (comment)
.

@cuongthai
Copy link

Recently, I work in a project and it needs to use viewpager and FadingActionBar. I based on your fragment demo and they doesnt work quite well.
I looked into the lib and I found the issue is that all the helpers in fragments overridden actionbar's Background Drawable while manipulating the drawables' alpha state. This causes the actionbar in current visible fragment doesnt get updated

So the idea is to use an FadingActionBarManager in the activity to keep states of all drawables and depends on which fragment is visible, it loads that drawable into actionbar.
In FadingActionBarHelper

@Override
    protected void setActionBarBackgroundDrawable(Drawable drawable) {
            mActionBarManager.setBackgroundDrawable(mCurrentFragmentTag, drawable);
    }

And in your fragment

@Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (isVisibleToUser) {
            mActionbarManager.loadActionBarForFragment(mFragmentTag);
        }
    }

The manager

public class FadingActionBarManager {
    private final ActionBar mActionBar;
    private Map<String, Drawable> actionBarDrawables;

    public FadingActionBarManager(ActionBar actionBar) {
        actionBarDrawables = new HashMap<String, Drawable>();
        mActionBar = actionBar;
    }

    public void loadActionBarForFragment(String fragmentTag) {
        if (actionBarDrawables.containsKey(fragmentTag)) {
            mActionBar.setBackgroundDrawable(actionBarDrawables.get(fragmentTag));
        }
    }

    public void setBackgroundDrawable(String tag, Drawable drawable) {
        actionBarDrawables.put(tag, drawable);
    }
}

I dont have time to create a pull request because it requires me to fix compatibility issues related to other extras which I dont need to use. But this works in my case. Hope this dirty fix help you guys

@Gperez88
Copy link

Gperez88 commented Jan 9, 2015

@cuongthai hello, I could spend the FadingActionBar Helper class with modifications?

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