【发布时间】:2018-01-23 13:38:33
【问题描述】:
我正在按照https://developer.android.com/training/appbar/index.html 中概述的步骤向我的活动添加操作栏。
但是,按照描述添加它涵盖了我的 ListView。该列表有 2 个条目。在我尝试添加操作栏之前,它是这样的:
在这里,我按照步骤调整了清单和我的活动布局:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar" />
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
现在看起来像这样:
我尝试使用 AppBarLayout 对象包装工具栏,如 https://stackoverflow.com/questions/35845629/actionbar-covering-my-activity 所示,但这不起作用。
如何将 ActionBar 添加到我的活动中而不覆盖 ListView。我想在活动的操作栏(不是溢出菜单)中添加几个按钮,以便提供添加到列表的选项。
【问题讨论】: