隐藏AppBar向下滚动时 [英] Hide AppBar when scrolling down
问题描述
我有一个 AppBar
和一个水平的LinearLayout(其中包括一个编辑文本和两个imagebuttons)在我的布局和其他东西。当用户向下滚动,我想 AppBar
(实际上是工具栏
隐藏即可。这是什么,我都试过了,该appbar是不是隐藏它只是停留在那里。我跟着克里斯巴内斯Cheesesquare样品。
这里是我的应用程序的截图:
当用户滚动,我想那 AppBar /工具栏
消失,而横向布局,其中包括的EditText,更换appbar在那里呆了。
你能告诉我什么,我做错了什么?
< android.support.v4.widget.DrawerLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:程序=http://schemas.android.com/apk/res-auto
机器人:ID =@ + ID / drawer_layout
机器人:layout_height =match_parent
机器人:layout_width =match_parent
机器人:fitsSystemWindows =真正的>< android.support.design.widget.CoordinatorLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:程序=http://schemas.android.com/apk/res-auto
机器人:ID =@ + ID / main_content
机器人:layout_width =match_parent
机器人:layout_height =match_parent> < android.support.design.widget.AppBarLayout
机器人:ID =@ + ID / appbar
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:主题=@风格/ ThemeOverlay.AppCompat.Dark.ActionBar> < android.support.v7.widget.Toolbar
机器人:ID =@ + ID / my_toolbar
机器人:layout_width =match_parent
机器人:layout_height =?ATTR / actionBarSize
机器人:ATTR / colorPrimary背景=
机器人:海拔=4DP
机器人:主题=@风格/ ThemeOverlay.AppCompat.ActionBar
应用:popupTheme =@风格/ ThemeOverlay.AppCompat.Light
的xmlns:机器人=http://schemas.android.com/apk/res/android
应用:layout_scrollFlags =滚动| enterAlways |抓拍
/> < /android.support.design.widget.AppBarLayout> < LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:工具=http://schemas.android.com/tools
的xmlns:程序=http://schemas.android.com/apk/res-auto的android:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=垂直
应用:layout_behavior =@字符串/ appbar_scrolling_view_behavior
工具:舒=@布局/ activity_show工具:上下文=com.example.bimpc1.sozluk.GosterActivity
机器人:背景=@色/白
机器人:ID =@ + ID / mylin> <查看
机器人:layout_width =FILL_PARENT
机器人:layout_height =30dp>
< /视图> <的LinearLayout
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:方向=横向
机器人:ID =@ + ID / topLayout
机器人:layout_alignParentTop =真
机器人:paddingLeft =10dp
机器人:paddingRight =10dp> <的ImageButton
机器人:ID =@ + ID / btn_sil
机器人:layout_width =45dp
机器人:layout_height =45dp
机器人:比重=中心
机器人:SRC =@绘制/删除
机器人:背景=@色/白
机器人:paddingRight =10dp
机器人:paddingLeft =10dp
机器人:paddingTop =0dp
机器人:paddingBottom会=15dp
/> <的EditText
机器人:比重=中心
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:ID =@ + ID / et_word
机器人:EMS =12
机器人:背景=@机器人:彩色/透明/> <的ImageButton
机器人:ID =@ + ID / btn_getir
机器人:layout_width =45dp
机器人:layout_height =45dp
机器人:比重=中心
机器人:SRC =@绘制/搜索
机器人:背景=@色/白
机器人:paddingRight =10dp
机器人:paddingLeft =10dp
机器人:paddingTop =0dp
机器人:paddingBottom会=15dp
/> < / LinearLayout中> <滚动型的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =FILL_PARENT
机器人:fillViewport =真
机器人:layout_below =@ + ID / topLayout
的xmlns:程序=http://schemas.android.com/apk/res-auto>
<! - 滚动视图里面.....很多意见 - > < /滚动型>< / LinearLayout中>< /android.support.design.widget.CoordinatorLayout>< /android.support.v4.widget.DrawerLayout>
其实,这设计似乎是wrong.Why?让我解释给你。
除了那些的xmlns:机器人=http://schemas.android.com/apk/res/android
这是没有必要的,或者使用:的android:layout_alignParentTop =真正的
在的LinearLayout
或者使用滚动型
下的内容,或者等等,好像你没有任何想法是怎么回事。(没问题)。
注意:的最重要的事情是,加入:
应用:layout_behavior =@字符串/ appbar_scrolling_view_behavior
这也这里提到:
HTTP://guides.$c$cpath.com/安卓/处理-卷轴与 - CoordinatorLayout
和这个标志应该隐藏该节:( exitUntilCollapsed
)
应用:layout_scrollFlags =滚动| exitUntilCollapsed
exitUntilCollapsed:
当滚动标志设置,向下滚动会
通常会导致整个内容到移动
块引用>所以最后: http://i.stack.imgur.com/qf1So.gif一>
希望这就是你要找的人,如果不是,请编辑您的问题,并添加一些截图。
随意更改标志或添加新的要达到什么你到底需要的。
更新:
如果你想隐藏
工具栏
(红色部分)崩溃后,只需在使用的CollapsingToolbarLayout
:应用:layout_scrollFlags =滚动|抓拍
最后,你会得到相同的结果(类似GOOGLEPLAY设计)。
codeS:
< android.support.v4.widget.DrawerLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:程序=http://schemas.android.com/apk/res-auto
机器人:ID =@ + ID / drawer_layout
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:fitsSystemWindows =真正的> < android.support.design.widget.CoordinatorLayout
机器人:ID =@ + ID / main_content
机器人:layout_width =match_parent
机器人:layout_height =match_parent> < android.support.v4.widget.NestedScrollView
机器人:layout_width =match_parent
机器人:layout_height =match_parent
应用:layout_behavior =@字符串/ appbar_scrolling_view_behavior> <! - 你可滚动的内容应该在这里 - 比如,
ViewPager或等 - > <的TextView
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_gravity =中心
机器人:scrollbarSize =15sp
机器人:文字=您的内容/> < /android.support.v4.widget.NestedScrollView> < android.support.design.widget.AppBarLayout
机器人:ID =@ + ID / appbar
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:主题=@风格/ ThemeOverlay.AppCompat.Dark.ActionBar> < android.support.design.widget.CollapsingToolbarLayout
机器人:ID =@ + ID / collapsingtoolbarly
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:fitsSystemWindows =真
应用:contentScrim =?ATTR / colorPrimary
应用:layout_scrollFlags =滚动|抓拍> < android.support.v7.widget.Toolbar
机器人:ID =@ + ID / my_toolbar
机器人:layout_width =match_parent
机器人:layout_height =?ATTR / actionBarSize
机器人:海拔=4DP
机器人:主题=@风格/ ThemeOverlay.AppCompat.ActionBar
应用:layout_collapseMode =针
应用:popupTheme =@风格/ ThemeOverlay.AppCompat.Light/> < ImageView的
机器人:layout_width =match_parent
机器人:layout_height =190dp
安卓了minHeight =190dp
机器人:scaleType =fitXY
机器人:SRC =@绘制/头
应用:layout_collapseMode =视差/>
< /android.support.design.widget.CollapsingToolbarLayout> <的LinearLayout
机器人:ID =@ + ID / mylin
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:方向=垂直> <查看
机器人:layout_width =FILL_PARENT
机器人:layout_height =30dp/> <的LinearLayout
机器人:ID =@ + ID / topLayout
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:方向=横向> <的ImageButton
机器人:ID =@ + ID / btn_sil
机器人:layout_width =45dp
机器人:layout_height =45dp
机器人:背景=@绘制/ ic_arrow_drop_up_black_24dp
机器人:比重=中心
机器人:paddingBottom会=15dp
机器人:paddingLeft =10dp
机器人:paddingRight =10dp
机器人:paddingTop =0dp/> <的EditText
机器人:ID =@ + ID / et_word
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:背景=@机器人:彩色/透明
机器人:EMS =12
机器人:比重=中心/> <的ImageButton
机器人:ID =@ + ID / btn_getir
机器人:layout_width =45dp
机器人:layout_height =45dp
机器人:背景=@绘制/ ic_arrow_drop_up_black_24dp
机器人:比重=中心
机器人:paddingBottom会=15dp
机器人:paddingLeft =10dp
机器人:paddingRight =10dp
机器人:paddingTop =0dp/> < / LinearLayout中> < / LinearLayout中> < /android.support.design.widget.AppBarLayout>
< /android.support.design.widget.CoordinatorLayout> <! - 最后,NavigationView - > <! - < android.support.design.widget.NavigationView
机器人:ID =@ + ID / nav_view
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =match_parent
机器人:layout_gravity =开始
应用:headerLayout =@布局/ app_header
应用:insetForeground =@彩色/ app_color_primary_dark
应用:菜单=@菜单/ navigation_menu/> - >< /android.support.v4.widget.DrawerLayout>结果:倒塌之后,searchedittext不会躲:
更新:新的方式:)
< android.support.v4.widget.DrawerLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:程序=http://schemas.android.com/apk/res-auto
机器人:ID =@ + ID / drawer_layout
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:fitsSystemWindows =真正的> < android.support.design.widget.CoordinatorLayout
机器人:ID =@ + ID / main_content
机器人:layout_width =match_parent
机器人:layout_height =match_parent> <的LinearLayout
机器人:ID =@ + ID / mylin
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:方向=垂直
应用:layout_behavior =@字符串/ appbar_scrolling_view_behavior> <查看
机器人:layout_width =FILL_PARENT
机器人:layout_height =30dp/> <的LinearLayout
机器人:ID =@ + ID / topLayout
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:方向=横向> <的ImageButton
机器人:ID =@ + ID / btn_sil
机器人:layout_width =45dp
机器人:layout_height =45dp
机器人:背景=@绘制/ ic_arrow_drop_up_black_24dp
机器人:比重=中心
机器人:paddingBottom会=15dp
机器人:paddingLeft =10dp
机器人:paddingRight =10dp
机器人:paddingTop =0dp/> <的EditText
机器人:ID =@ + ID / et_word
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:背景=@机器人:彩色/透明
机器人:EMS =12
机器人:比重=中心/> <的ImageButton
机器人:ID =@ + ID / btn_getir
机器人:layout_width =45dp
机器人:layout_height =45dp
机器人:背景=@绘制/ ic_arrow_drop_up_black_24dp
机器人:比重=中心
机器人:paddingBottom会=15dp
机器人:paddingLeft =10dp
机器人:paddingRight =10dp
机器人:paddingTop =0dp/> < / LinearLayout中> < / LinearLayout中> < android.support.v4.widget.NestedScrollView
机器人:layout_width =match_parent
机器人:layout_height =match_parent
应用:layout_behavior =@字符串/ appbar_scrolling_view_behavior> <! - 你可滚动的内容应该在这里 - 比如,
ViewPager或等 - > <的TextView
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_gravity =中心
机器人:scrollbarSize =15sp
机器人:文字=您的内容/> < /android.support.v4.widget.NestedScrollView> < android.support.design.widget.AppBarLayout
机器人:ID =@ + ID / appbar
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:主题=@风格/ ThemeOverlay.AppCompat.Dark.ActionBar> < android.support.v7.widget.Toolbar
机器人:ID =@ + ID / my_toolbar
机器人:layout_width =match_parent
机器人:layout_height =?ATTR / actionBarSize
机器人:海拔=4DP
应用:layout_scrollFlags =滚动| enterAlways
机器人:主题=@风格/ ThemeOverlay.AppCompat.ActionBar
应用:popupTheme =@风格/ ThemeOverlay.AppCompat.Light/> < /android.support.design.widget.AppBarLayout>
< /android.support.design.widget.CoordinatorLayout> <! - 最后,NavigationView - > <! - < android.support.design.widget.NavigationView
机器人:ID =@ + ID / nav_view
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =match_parent
机器人:layout_gravity =开始
应用:headerLayout =@布局/ app_header
应用:insetForeground =@彩色/ app_color_primary_dark
应用:菜单=@菜单/ navigation_menu/> - >< /android.support.v4.widget.DrawerLayout>结果:
I have an
AppBar
and a horizontal linearlayout (which includes an edit text and two imagebuttons) and other things in my layout. When user scrolls down, I wantAppBar
(actually, theToolbar
to hide. This is what I have tried, the appbar isn't hiding it just stays there. I followed the Chris Banes Cheesesquare Sample.Here is the screenshot of my app:
When user scrolls, I want that
AppBar/Toolbar
to disappear, and that horizontal layout, which includes the edittext, replace the appbar and stayed there.Can you tell me what I am doing wrong?
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_height="match_parent" android:layout_width="match_parent" android:fitsSystemWindows="true"> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <android.support.v7.widget.Toolbar android:id="@+id/my_toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:elevation="4dp" android:theme="@style/ThemeOverlay.AppCompat.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" xmlns:android="http://schemas.android.com/apk/res/android" app:layout_scrollFlags="scroll|enterAlways|snap" /> </android.support.design.widget.AppBarLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:showIn="@layout/activity_show" tools:context="com.example.bimpc1.sozluk.GosterActivity" android:background="@color/white" android:id="@+id/mylin"> <View android:layout_width="fill_parent" android:layout_height="30dp"> </View> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:id="@+id/topLayout" android:layout_alignParentTop="true" android:paddingLeft="10dp" android:paddingRight="10dp"> <ImageButton android:id="@+id/btn_sil" android:layout_width="45dp" android:layout_height="45dp" android:gravity="center" android:src="@drawable/delete" android:background="@color/white" android:paddingRight="10dp" android:paddingLeft="10dp" android:paddingTop="0dp" android:paddingBottom="15dp" /> <EditText android:gravity="center" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/et_word" android:ems="12" android:background="@android:color/transparent"/> <ImageButton android:id="@+id/btn_getir" android:layout_width="45dp" android:layout_height="45dp" android:gravity="center" android:src="@drawable/search" android:background="@color/white" android:paddingRight="10dp" android:paddingLeft="10dp" android:paddingTop="0dp" android:paddingBottom="15dp" /> </LinearLayout> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="fill_parent" android:fillViewport="true" android:layout_below="@+id/topLayout" xmlns:app="http://schemas.android.com/apk/res-auto"> <!--many views inside scrollview..... --> </ScrollView> </LinearLayout> </android.support.design.widget.CoordinatorLayout> </android.support.v4.widget.DrawerLayout>
解决方案Actually, that design seems to be wrong.Why? let me explain that to you.
Except those
xmlns:android="http://schemas.android.com/apk/res/android"
which it wasn't necessary or using:android:layout_alignParentTop="true"
in theLinearLayout
or using thatScrollView
under the contents or etc, seems like you don't have any idea what's going on.(no problem).Note: the most important thing was, adding:
app:layout_behavior="@string/appbar_scrolling_view_behavior"
which also mentioned here:http://guides.codepath.com/android/Handling-Scrolls-with-CoordinatorLayout
And this flag should hide that section:(
exitUntilCollapsed
)app:layout_scrollFlags="scroll|exitUntilCollapsed"
exitUntilCollapsed:
When the scroll flag is set, scrolling down will normally cause the entire content to move.So finally: http://i.stack.imgur.com/qf1So.gif
Hope this is what you were looking for, if it wasn't please edit your question and add some screenshots.
Feel free to change the flags or add a new to achieve what you exactly need.
UPDATE:
If you want to hide that
Toolbar
(red section) after collapsing, just use this in theCollapsingToolbarLayout
:app:layout_scrollFlags="scroll|snap"
Finally, you will get the same result(something like googleplay design).
Codes:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <android.support.design.widget.CoordinatorLayout android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v4.widget.NestedScrollView android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <!-- Your Scrollable contents should be here - such as, ViewPager or etc --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:scrollbarSize="15sp" android:text="You Contents" /> </android.support.v4.widget.NestedScrollView> <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/collapsingtoolbarly" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" app:contentScrim="?attr/colorPrimary" app:layout_scrollFlags="scroll|snap"> <android.support.v7.widget.Toolbar android:id="@+id/my_toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:elevation="4dp" android:theme="@style/ThemeOverlay.AppCompat.ActionBar" app:layout_collapseMode="pin" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> <ImageView android:layout_width="match_parent" android:layout_height="190dp" android:minHeight="190dp" android:scaleType="fitXY" android:src="@drawable/header" app:layout_collapseMode="parallax" /> </android.support.design.widget.CollapsingToolbarLayout> <LinearLayout android:id="@+id/mylin" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <View android:layout_width="fill_parent" android:layout_height="30dp" /> <LinearLayout android:id="@+id/topLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <ImageButton android:id="@+id/btn_sil" android:layout_width="45dp" android:layout_height="45dp" android:background="@drawable/ic_arrow_drop_up_black_24dp" android:gravity="center" android:paddingBottom="15dp" android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="0dp" /> <EditText android:id="@+id/et_word" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@android:color/transparent" android:ems="12" android:gravity="center" /> <ImageButton android:id="@+id/btn_getir" android:layout_width="45dp" android:layout_height="45dp" android:background="@drawable/ic_arrow_drop_up_black_24dp" android:gravity="center" android:paddingBottom="15dp" android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="0dp" /> </LinearLayout> </LinearLayout> </android.support.design.widget.AppBarLayout> </android.support.design.widget.CoordinatorLayout> <!-- And finally, NavigationView --> <!-- <android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" app:headerLayout="@layout/app_header" app:insetForeground="@color/app_color_primary_dark" app:menu="@menu/navigation_menu" /> --> </android.support.v4.widget.DrawerLayout>
Results: after collapsing, the searchedittext won't hide:
UPDATE: New way :)
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <android.support.design.widget.CoordinatorLayout android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:id="@+id/mylin" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <View android:layout_width="fill_parent" android:layout_height="30dp" /> <LinearLayout android:id="@+id/topLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <ImageButton android:id="@+id/btn_sil" android:layout_width="45dp" android:layout_height="45dp" android:background="@drawable/ic_arrow_drop_up_black_24dp" android:gravity="center" android:paddingBottom="15dp" android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="0dp" /> <EditText android:id="@+id/et_word" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@android:color/transparent" android:ems="12" android:gravity="center" /> <ImageButton android:id="@+id/btn_getir" android:layout_width="45dp" android:layout_height="45dp" android:background="@drawable/ic_arrow_drop_up_black_24dp" android:gravity="center" android:paddingBottom="15dp" android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="0dp" /> </LinearLayout> </LinearLayout> <android.support.v4.widget.NestedScrollView android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <!-- Your Scrollable contents should be here - such as, ViewPager or etc --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:scrollbarSize="15sp" android:text="You Contents" /> </android.support.v4.widget.NestedScrollView> <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <android.support.v7.widget.Toolbar android:id="@+id/my_toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:elevation="4dp" app:layout_scrollFlags="scroll|enterAlways" android:theme="@style/ThemeOverlay.AppCompat.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> </android.support.design.widget.AppBarLayout> </android.support.design.widget.CoordinatorLayout> <!-- And finally, NavigationView --> <!-- <android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" app:headerLayout="@layout/app_header" app:insetForeground="@color/app_color_primary_dark" app:menu="@menu/navigation_menu" /> --> </android.support.v4.widget.DrawerLayout>
Results:
这篇关于隐藏AppBar向下滚动时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!