我正在我的应用程序中实现 ListView 。我正在尝试为 android 6.0 构建我的应用程序并选择主题“DarkActionBar”。我现在在activity_main.xml 中有此代码。
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.mycompany.www.mynotes.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<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/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<ListView
android:id="@+id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</android.support.design.widget.CoordinatorLayout>
我刚刚在此代码中添加了一个 ListView (替换 TextView )。当我创建项目时,其余代码已经存在。
现在我正在 ListView 中随机添加一些项目。 现在的问题是, ListView 最上面的项目位于工具栏后面,如下图所示。如何修复它?我希望此 ListView 在工具栏下方启动。
最佳答案
您必须将 app:layout_behavior
添加到 LiveView
中:
<ListView
android:id="@+id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
关于java - Android 中工具栏与元素重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36970445/