Java 如何停止在折叠工具栏布局上滚动,使其不';不要完全崩溃

Java 如何停止在折叠工具栏布局上滚动,使其不';不要完全崩溃,java,android,performance,android-layout,android-intent,Java,Android,Performance,Android Layout,Android Intent,大家好,你们能不能建议我如何阻止它。请看下面的截图 向上滚动后,应在应用程序工具栏下方停止,距离顶部至少200dp 您可以执行以下操作 <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http:/

大家好,你们能不能建议我如何阻止它。请看下面的截图

向上滚动后,应在应用程序工具栏下方停止,距离顶部至少200dp


您可以执行以下操作

<?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
高度将更大
Toolbar
高度(在您的场景中
Toolbar
高度为
200dp
,因此我保留了
AppBarLayout
作为
280dp
)希望这就是您想要的

设置最小折叠高度

android:minHeight="200dp"

在工具栏下添加多个项目,因为该项目只有一个,所以不会滚动!请你解释清楚。很抱歉我误解了你的要求,你希望工具栏停止到200dp,对吗?但是你做了什么?你能分享代码吗?你实现了吗?非常感谢。请您避免使用硬编码值并删除。我说的工具栏和appbarlayout高度。我们无法动态设置。我在
dimens.xml
中使用了它们,所以它不是硬编码的!我在我的
dimens.xml
的“各种值”文件夹中有不同的值。很好。谢谢。我没有看到它。我只是在检查它。但它工作得很好。