如何停止在CollapsingToolbarLayout上滚动,以便它不会完全崩溃 [英] How to Stop scroll on CollapsingToolbarLayout so it doesn't completely collapse

查看:172
本文介绍了如何停止在CollapsingToolbarLayout上滚动,以便它不会完全崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


您好Everone能否请您建议如何阻止它。请查看以下截图。

Hi Everone could you please suggest me how to stop it .please have a look at following screenshot.


向上滚动后,它应该停止在应用工具栏最低200dp之下

After scrolling up it should stop below app tool bar minimum 200dp from TOP

推荐答案

你可以做如下所示

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/app_bar_height" //280dp
        android:fitsSystemWindows="true"
        android:theme="@style/AppTheme.AppBarOverlay">

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

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="@dimen/my_toolbar_bar_height" //200dp
                app:layout_collapseMode="pin"
                app:popupTheme="@style/AppTheme.PopupOverlay"/>

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

<include layout="@layout/content_scrolling"/> // This is place holder for content/list

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

AppBarLayout 高度将大于工具栏身高(在您的方案工具栏身高 200dp 所以我保持 AppBarLayout as 280dp )希望这就是你要找的!

AppBarLayout height will be greater the Toolbar height (In your scenario Toolbar height is 200dp so I kept AppBarLayout as 280dp) Hope this is what you looking for!

这篇关于如何停止在CollapsingToolbarLayout上滚动,以便它不会完全崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆