ManuelPeinado / FadingActionBar

Android library implementing a fading effect for the action bar, similar to the one found in the Play Music app
Apache License 2.0
2.87k stars 677 forks source link

Solution for weird layout problem found! #30

Open ghost opened 10 years ago

ghost commented 10 years ago

soo, I got a solution to fix the problem where the background flashes to foreground if the app get's continued.

in Rootlayout just comment out

     //get last header and listViewBackground position
    int headerTopPrevious = mHeaderContainer.getTop();
    int listViewBackgroundTopPrevious = mListViewBackground != null ? mListViewBackground.getTop() : 0;

    //relayout
    super.onLayout(changed, left, top, right, bottom);

    //revert header top position
    int headerTopCurrent = mHeaderContainer.getTop();
    if (headerTopCurrent != headerTopPrevious) {
        mHeaderContainer.offsetTopAndBottom(headerTopPrevious - headerTopCurrent);
    }
    //revert listViewBackground top position
    int listViewBackgroundTopCurrent = mListViewBackground != null ? mListViewBackground.getTop() : 0;
    if (listViewBackgroundTopCurrent != listViewBackgroundTopPrevious) {
        mListViewBackground.offsetTopAndBottom(listViewBackgroundTopPrevious - listViewBackgroundTopCurrent);
    }
}

this.

After that it works like a charm for me :)

Sorry i did not send a pull request but I don't actually use git

ManuelPeinado commented 10 years ago

Hi Fabian, thanks for helping out.

Unfortunately, I've tried your fix but the ListView sample still fails after an orientation change. What problem does it fix then?

ghost commented 10 years ago

I'm using a ViewPager as headerLayoutoverlay and a listview with a custom adapter

before i applied the fix, if i clicked an element from inside the viewpager (I have a gridview on each page), the layout got messed up.

the fix works for me even if i change the orientation and even if from inside the gridview when I set setSelection

Ill try the fix on your sample and then edit my answer

ghost commented 10 years ago

As I said before, the weird hide/show is now gone, but now, my listview onclicklisteeners are not working like they should..

I have to click them twice.. Looks like the up does not get updated..

ghost commented 10 years ago

Hey, uhm, could the problem with this has to do with the requestLayout?