SearchView 出现/消失 [英] SearchView appears/disappears
本文介绍了SearchView 出现/消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序中,我想创建如下内容:
我希望所有 AppBar 出现/消失,但使用 CollapingToolbarLayout 对我不起作用.
我尝试过类似的东西:
向下滚动屏幕时会隐藏ToolBar
In my application I'd like to create something like this:
I want all the AppBar to appear / disappear but using CollapingToolbarLayout doesn't work for me.
I tried with something like:
<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>
but it doesn't work.
Can someone please help me?
Thanks in advance.
解决方案 You have to use Cheesesquare
demo to get what you want..
Demo link :
https://github.com/chrisbanes/cheesesquare
Output :
normal screen.
when scroll down screen it will hide ToolBar
这篇关于SearchView 出现/消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文