Tabs 尽管实现了所有必需的参数,但CoordinatorLayout不会隐藏滚动工具栏
这是我的设置,我正在运行一个抽屉布局,其中是一个协调布局,包含一个AppBarLayout和一个nestedscrollview。我试图让nestedscrollview正常滚动,工具栏在向下滚动时隐藏,在向上滚动时重新显示。附件是我的XML代码。如有任何帮助,我将不胜感激。。已阅读所有相关问题并实施其答案,但未取得任何成功Tabs 尽管实现了所有必需的参数,但CoordinatorLayout不会隐藏滚动工具栏,tabs,material-design,drawerlayout,toolbars,android-coordinatorlayout,Tabs,Material Design,Drawerlayout,Toolbars,Android Coordinatorlayout,这是我的设置,我正在运行一个抽屉布局,其中是一个协调布局,包含一个AppBarLayout和一个nestedscrollview。我试图让nestedscrollview正常滚动,工具栏在向下滚动时隐藏,在向上滚动时重新显示。附件是我的XML代码。如有任何帮助,我将不胜感激。。已阅读所有相关问题并实施其答案,但未取得任何成功 <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/a
<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_admin"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/admincoordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="@+id/app_bar"
layout="@layout/app_bar"
app:layout_scrollFlags="scroll|enterAlways" />
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/adminrelScroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/drawer_header"
app:menu="@menu/menu_drawer" />
我认为利用新技术将有助于… 一些示例中的简短说明演示了如何在折叠工具栏布局中包装工具栏,并通过设置Layoutu collapseMode自定义效果 更新 我认为在ListView中添加onScrollListener并显示/隐藏工具栏,如以下示例所示:
getWindow().requestFeature(Window.FEATURE\u ACTION\u BAR\u覆盖);
setOnScrollListener(新的OnScrollListener(){
int mLastFirstVisibleItem=0;
@凌驾
public void onScrollStateChanged(AbsListView视图,int scrollState){}
@凌驾
public void onScroll(AbsListView视图、int firstVisibleItem、int visibleItemCount、int totalItemCount){
if(view.getId()==listView.getId()){
final int currentFirstVisibleItem=listView.getFirstVisiblePosition();
如果(currentFirstVisibleItem>mLastFirstVisibleItem){
getSupportActionBar().hide();
}else if(currentFirstVisibleItem
一周来,我遇到了同样的问题,并尝试了几乎所有的方法来解决它。
然而,我设法解决了这个问题
在那里你有一些像
<include
android:id="@+id/app_bar"
layout="@layout/app_bar"
app:layout_scrollFlags="scroll|enterAlways" />
似乎出于某种原因,使用
标记时使用协调布局滚动不起作用,正如@Farbod Salamat Zadehas之前所说:协调布局在使用
标记时不起作用。
但是您可以这样使用
:
<include
android:id="@+id/app_bar"
layout="@layout/app_bar" />
参数app:layout_scrollFlags=“scroll | enterally”
只要移动到app_bar.xml中就可以了,如果你有一个(额外的?)大工具栏在滚动时恢复到正常大小,那么它不是一个可折叠的工具栏布局,我想要实现的是在滚动时简单地隐藏正常大小的工具栏。。希望我的问题清楚:)对我来说也是同样的问题,滚动事件根本不起作用。你得到答案了吗?这里也是。这是weird@All任何人都能找到解决办法。这真让我头疼。如果你觉得我的答案有用,你能接受吗?;)我太讨厌了,这就是我一直需要的!!谢谢你!
<android.support.v7.widget.Toolbar
android:id="@+id/main_toolbar"
style="@style/AppTheme.Toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
app:layout_scrollFlags="scroll|enterAlways"/>
<include
android:id="@+id/app_bar"
layout="@layout/app_bar" />