android - 如何在android中滚动时固定工具栏?

标签 android material-design toolbar android-scroll

在发布这个问题之前,我已经研究了所有之前的问题,之前的解决方案都不适合我。我需要在滚动时使我的 Toolbar 静态,它在滚动时上升,但我需要使其静态我该怎么做。现在让我解释一下到目前为止我尝试过的所有方法,

  1. 我已经进入windowSoftInputMode调整调整大小

  2. fitwindows 真正的布局

这是我写的代码:

这是主要的 CoordinatorLayout:

<?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"
    android:id="@+id/main_content"
    android:fitsSystemWindows="true"
    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/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:layout_scrollFlags="scroll|enterAlways" />
    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/activity_incident"
       />



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

这是布局文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/activity_incident"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">
    <android.support.v7.widget.RecyclerView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/incident_recyclerview"
        android:divider="#fff"
         android:keepScreenOn="true"
        android:dividerHeight="0.5dp"
        />
</RelativeLayout>

我只想让我的 Toolbar 静态 我怎样才能实现 提前谢谢!!

最佳答案

Toolbar 中删除 app:layout_scrollFlags="scroll|enterAlways" 并检查滚动。

关于android - 如何在android中滚动时固定工具栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42106122/

相关文章:

php - 使用 phpmyadmin 显示通知

html - 使用卡片设计 Material Design Lite Grid,使其看起来像 Google Keep

android - 具有不同工具栏布局的单个 Activity 和多个 Fragment

c++ - 如何更改子窗口在父窗口中的位置并显示工具栏?

cocoa - 如何在Cocoa中添加其他应用程序的图标到工具栏?

android - 显示在 recyclerview 中点击的项目的详细信息

android - LocationListener 的 AbstractMethodError 甚至是使用 compileSdkVersion 30 构建的应用程序

android - 为大图像设置更高的 Drawable 分辨率

android - 更改 View 颜色但保持波纹和触摸状态

android - 另一个 Activity 出现并覆盖屏幕尺寸的一半