这是我的布局xml代码
我已经有listview scroll listener的回调,但是如果我这样做的话
collapsingToolbarLayout.setVisibility(View.GONE);这是简单的隐藏工具栏的地方滚动效果,但我想滚动效果,请帮助。
<android.support.design.widget.AppBarLayout
android:id="@+id/id_toolbar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:visibility="gone"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|exitUntilCollapsed" />
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/id_toolbar_container">
<android.support.design.widget.AppBarLayout
android:id="@+id/id_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="0dp">
//This is the toolbar which i want to hide on scroll of listview
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsingToolBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="enterAlwaysCollapsed">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="5dp"
app:tabMinWidth="75dp"
app:tabIndicatorColor="@color/deep_blue"
app:tabSelectedTextColor="@color/background"
app:tabTextAppearance="@style/MyTabLayoutTextAppearance"
app:tabTextColor="@color/myGrey" />
</RelativeLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
发布于 2016-03-14 16:18:23
滚动行为依赖于支持嵌套滚动的视图,这是在视图树中向上传播滚动事件所必需的。
在api-21中添加了setNestedScrollingEnabled()方法。为了让折叠工具栏在api-21及更高版本上工作,在ListView上调用它:
myListView.setNestedScrollingEnabled(true);为了让它在较低的api级别上工作,您需要将您的ListView转换为支持向下滚动到api-7的RecyclerView,因为它来自v7支持库。
有关使用RecyclerView的完整示例,请参阅here。
https://stackoverflow.com/questions/35981613
复制相似问题