【发布时间】:2017-06-25 15:47:10
【问题描述】:
在发布这个问题之前,我已经研究了所有以前的问题,以前的解决方案都没有对我有用。我需要在滚动时将我的Toolbar 设为静态,在滚动时它会上升,但我需要将其设为静态我该怎么做。现在让我解释一下我到目前为止尝试过的所有方法,
我已经输入
windowSoftInputMode调整resizefitwindows真正的布局
这是我写的代码:
这是主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 静态我怎样才能实现提前谢谢!!
【问题讨论】:
-
@M.Yogeshwaran 您想将工具栏保持在同一位置,或者这又意味着什么使其成为静态
-
与布局无关,我不能与协调器布局一起使用
-
@Charuක 你好,我不希望工具栏移动它需要是静态的
-
在 AppBarLayout 之后添加 Nested ScrollView 就可以了。
标签: android material-design toolbar android-scroll