1

新的 Android 工具栏为我们提供了一些使用操作栏的灵活性,但我遇到了一个问题。我在我的活动布局中使用工具栏作为操作栏(我猜现在“AppBar”是正确的名称)。当用户关注编辑文本时,系统会向上滚动内容以让用户看到该字段。它还向上和离开屏幕滚动工具栏。这是一个问题,因为导航位于工具栏上,现在对用户隐藏。

<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>

我们如何才能保持 ToolBar 就位?

4

1 回答 1

1

您可以通过在工具栏下方放置一个 ScrollView 并将内容放入其中来做到这一点。还需要在活动上设置 android:windowSoftInputMode="adjustResize"。另外,为了避免动作模式下推工具栏,添加这个属性

android:windowActionModeOverlay="true"
于 2014-11-13T16:14:25.267 回答