在发布这个问题之前,我已经研究了所有之前的问题,之前的解决方案都不适合我。我需要在滚动时使我的 Toolbar
静态,它在滚动时上升,但我需要使其静态我该怎么做。现在让我解释一下到目前为止我尝试过的所有方法,
我已经进入
windowSoftInputMode
调整调整大小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/