RubenGees RubenGees - 3 months ago 16
Android Question

Parallax image is not displayed properly on support lib 24.2.0

I just updated to the new support lib version 24.2.0 and experienced the following problem with parallax images in a

CollapsingToolbarLayout
:

24.1.1

How it looked like on
24.1.1


24.2.0

How it now looks like on
24.2.0


This examples are from the Cheesesquare demo app which I did not modify apart from the support lib version. This is the relevant layout file.

It looks like the image is not properly overlaying the
CollapsingToolbarLayout
anymore.

Does anybody know what is causing this and/or how to fix it?

Answer

It looks like a bug and it was already reported https://code.google.com/p/android/issues/detail?id=220389

EDITED

According to Chris Banes post

The issue is that the ImageView is receiving the standard View#fitSystemWindows padding. You can set the following on the ImageView for a quick workaround:

ViewCompat.setOnApplyWindowInsetsListener(this, OnApplyWindowInsetsListener() {
    @Override
    public WindowInsetsCompat onApplyWindowInsets(View v,
            WindowInsetsCompat insets {
        return insets.consumeSystemWindowInsets();
    }
});