Using static fragments with CoordinatorLayout of the new Design Support Library

881 views Asked by At

I've been experimenting with the new offerings of the library and I just can't wrap my head around customizing it the way I want.

I am taking as a reference this sample code: https://github.com/chrisbanes/cheesesquare

I have successfully managed to add a static fragment (contains some FrameLayout with recyclerView and additional empty views) as the child of the CoordinatorLayout, which works as expected when scrolling the (ugly) recycler view inside it.

The working gist and the result:

Recycler view with elements

I am only trying to add one extra CardView above my fragment, which should also have the same effect on the toolbar when dragged upwards. I tried adding them both to a LinearLayout inside a NestedScrollView, together with other various combinations, of which none was successful. Whenever I tap on the cardview, they are displaced and never again in their own place. Moreover, dragging the cardview still fades out the toolbar, but nothing else happens.

The non-working gist and the result:

Empty recycler view

1

There are 1 answers

0
Jeff Lockhart On

I came across a different issue using CoordinatorLayout as the container for my fragments: https://code.google.com/p/android/issues/detail?id=179600

It seems CoordinatorLayout has a number of issues with this use case. The solution is likely to use a FrameLayout instead to contain your fragment, then put the CoordinatorLayout as the top level container of your fragment's UI.