2016-07-15 61 views
-1

在我的申请,我想是这样创造的东西:搜索查看出现/消失

Gif1

我希望所有的AppBar出现/消失,但使用CollapingToolbarLayout不会为我工作。

我试过的东西,如:

<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:fitsSystemWindows="true"> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/app_bar_layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
    android:fitsSystemWindows="true"> 

    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapsing_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed" 
     app:contentScrim="?attr/colorPrimary" 
     app:expandedTitleMarginStart="48dp" 
     app:expandedTitleMarginEnd="64dp" 
     android:fitsSystemWindows="true"> 

     <SearchView 
      android:id="@+id/searchView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:scaleType="centerCrop" 
      android:fitsSystemWindows="true" 
      app:layout_collapseMode="parallax"/> 


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

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

<android.support.v4.widget.NestedScrollView 
    android:id="@+id/scroll" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:clipToPadding="false" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

[...] 

</android.support.v4.widget.NestedScrollView> 


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

,但它不工作。

有人可以帮我吗?

在此先感谢。

回答

0

你必须使用Cheesesquare演示,得到你想要的..

演示链接:

https://github.com/chrisbanes/cheesesquare

输出:

正常屏幕。

enter image description here

当向下滚动屏幕会隐藏ToolBar

enter image description here

+0

这似乎正是我要找的,我会尽力,感谢您 – Jigen

+0

@Jigen如果我的回答是乐于助人然后接受它.. – Ironman

+0

当然可以,但请让我先试试吧:) – Jigen