Android 工具栏在窗体上从屏幕上滚动
新的安卓工具栏给了我们一些灵活性,我们可以用actionbar做什么,但我遇到了一个问题。我将活动布局中的工具栏用作actionbar(我想AppBar现在是正确的名称)。当用户关注edittext时,系统会向上滚动内容,让用户看到该字段。它还可以向上滚动工具栏并将其移出屏幕。这是一个问题,因为导航位于工具栏上,现在对用户隐藏Android 工具栏在窗体上从屏幕上滚动,android,android-5.0-lollipop,android-toolbar,Android,Android 5.0 Lollipop,Android Toolbar,新的安卓工具栏给了我们一些灵活性,我们可以用actionbar做什么,但我遇到了一个问题。我将活动布局中的工具栏用作actionbar(我想AppBar现在是正确的名称)。当用户关注edittext时,系统会向上滚动内容,让用户看到该字段。它还可以向上滚动工具栏并将其移出屏幕。这是一个问题,因为导航位于工具栏上,现在对用户隐藏 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize">
</Toolbar>
</LinearLayout>
如何保持工具栏的位置?您可以在工具栏下方放置一个滚动视图并将内容放入其中。还需要在活动上设置android:WindowsOfInputMode=“adjustResize”。另外,为了避免actionmode向下推工具栏,请添加此属性
android:windowActionModeOverlay="true"
等等,你的工具栏是在滚动视图还是什么的?当您这样做时,工具栏不会固有地滚动。这是上面的布局,减去编辑文本、图像等。没有滚动视图。使用android:Theme.Material.NoActionbar作为父主题。还注意到状态栏颜色也会向上滚动。@tyczj它确实会在我的Nexus 5上滚动最新的5.0图像。如果你的工具栏是透明的,而内容(比如ImageView)故意显示在下面,这就没用了。