android - 查看重叠的应用程序兼容性支持操作栏?

标签 android android-layout android-actionbar android-view android-appcompat

我让一位 friend 测试我的应用程序,但他注意到布局存在一些奇怪的问题。 ListView 中的所有 View 都将悬停在操作栏上。
问题是,我无法在我自己的设备或模拟器上重现它,所以我假设它特定于某些版本的 Android?有谁知道这里的问题
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.brainicism.summonertracker.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>

    <include layout="@layout/content_main" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:src="@drawable/ic_add" />


</android.support.design.widget.CoordinatorLayout>

content_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="0dp"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity">

    <ListView
        android:id="@+id/trackingList"
        android:layout_width = "match_parent"
        android:layout_height="wrap_content" />

</LinearLayout>

主要 Activity

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

Text overlaying actionbar

Buttons overlaying actionbar

最佳答案

使用我的 content_main.xml 中的以下属性解决了这个问题

android:layout_marginTop="?attr/actionBarSize"

关于android - 查看重叠的应用程序兼容性支持操作栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34690344/

相关文章:

java - Xamarin - 使用 JavaScript 调用 Android 函数

java - Android 比较两个微调器和新 Activity 的 Intent

android-为什么自定义actionbar不填满宽度

java - 无法理解 Fragments/Tabs + ActionBar + swipe (ICS)

android - 具有向后兼容性 android 的抽屉导航

android - android中的加密

android - 如何使用导航架构组件从 fragment 中获取结果?

android - 为什么即使在 Firebase 崩溃报告上上传了 mapping.txt 后,日志中仍会出现混淆代码?

android - 从 API 级别 < Android 26 (Oreo) 的 RGB 值创建颜色对象

android - Android 操作栏上的左菜单图标