2

I'm trying to achieve an effect like the videos in the "behavior section" at this URL ( Google Design official site ). It's the same effect of Google Photo, I guess, with a search bar on the top of the RecyclerView that disappear/appear on scrolling up/down

I don't know how to get it, I started with CoordinatorLayout and AppBarLayout, but I can't get the RecyclerView visible behind the AppBarLayout, it always remains white, covering the RecyclerView as show below ( result and code [edit: added image with layout layers] ).

Or it's a custom CoordinatorLayout.Behavior ?

Any help or suggestion would be appreciated, thank you

result

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsingToolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|enterAlways"
            android:background="@android:color/transparent">

            <SearchView
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="@android:color/holo_green_light"
                android:layout_marginTop="40dp"
                android:layout_marginStart="16dp"
                android:layout_marginEnd="16dp"
                android:layout_marginBottom="16dp"/>

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

</android.support.design.widget.CoordinatorLayout>

Sample layout

enter image description here

marco
  • 3,193
  • 4
  • 28
  • 51
  • Do you mean the solid white border that overlaps the RecyclerView when scrolling down? – GPack Nov 08 '16 at 08:33
  • Yes, just that view. I'm trying to get the same effect as indicated in the google documentation linked in the question – marco Nov 08 '16 at 08:37
  • Try removing the margins' properties on SearchView, and adding similar paddings' properties on AppBarLayout. – GPack Nov 08 '16 at 08:50
  • It doesnt work, but I have more clear the problem. It's "something" under the AppBar and over the RW ( still not resolved, i will edit the question soon ), thank you – marco Nov 08 '16 at 09:15

2 Answers2

3

It is definitely a custom CoordinatorLayout.Behavior. After some searches and readings ( most important, some inspirations, more inspirations, and the foundamentals ), I got what I wanted with the following layout

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        android:paddingEnd="@dimen/activity_horizontal_margin"
        android:paddingStart="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/grid_spacing_header"/>

    <SearchView
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:layout_marginEnd="@dimen/activity_horizontal_margin"
        android:layout_marginStart="@dimen/activity_horizontal_margin"
        android:layout_marginTop="@dimen/searchbar_top"
        app:layout_behavior=".SearchBarBehavior"/>

</android.support.design.widget.CoordinatorLayout>

with my own SearchBarBehavior that extends CoordinatorLayout.Behavior [code still incomplete]

Community
  • 1
  • 1
marco
  • 3,193
  • 4
  • 28
  • 51
0

try to set CoordinatorLayout also transparent

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent">
grantonzhuang
  • 557
  • 4
  • 6
  • It doesnt work, but I have more clear the problem. It's "something" under the AppBar and over the RW ( still not resolved, i will edit the question soon ), thank you – marco Nov 08 '16 at 09:15