【问题标题】:Toolbar overlapping listView工具栏重叠 listView
【发布时间】:2018-01-04 10:41:03
【问题描述】:

我的工具栏覆盖了列表视图。

工具栏.xml

<?xml version="1.0" encoding="utf-8"?>

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/my_toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorAccent"
    android:elevation="4dp"
    android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" />

视图.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.ismael.fisiopia.views.TratamientosActivity">

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


        <ListView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/tratamientoview"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        </ListView>

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/btnAddTrat"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="end|bottom"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:layout_marginBottom="36dp"
            android:layout_marginRight="36dp"
            android:clickable="true" />


    <RelativeLayout
        android:id="@+id/progressLayoutTrat"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#B0000000"
        android:visibility="gone">

        <ProgressBar
            android:id="@+id/progressBarTratamientos"
            style="?android:attr/progressBarStyleLarge"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="13dp"
            android:layout_marginStart="13dp"
            android:paddingTop="250dp"
            android:visibility="gone" />

    </RelativeLayout>
</RelativeLayout>

我试着把这行:app:layout_behavior="@string/appbar_scrolling_view_behavior" 但不起作用

我在一个 relativeLayout 中也有一个进度条,因为当某些操作正在计算到 de app 中时,我需要更改背景颜色。

你能帮帮我吗? 谢谢:)

【问题讨论】:

    标签: android xml listview layout toolbar


    【解决方案1】:
    1. 将根RelativeLayout 替换为CoordinatorLayout

    2. 将父 AppBarLayout 添加到 Toolbar

    3. 将滚动行为添加到您的ListView

    【讨论】:

      【解决方案2】:

      工具栏中的 Popup 主题错误 替换这个

      app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" 
      

      进入这个

      app:popupTheme="@style/AppTheme.PopupOverlay"
      

      【讨论】:

        猜你喜欢
        • 2023-03-09
        • 2017-12-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-02-20
        • 2015-05-02
        • 2016-03-03
        相关资源
        最近更新 更多