工具栏重叠listView
Toolbar overlapping listView
我的工具栏覆盖了列表视图。
Toolbar.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" />
View.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
替换为 CoordinatorLayout
将父级 AppBarLayout
添加到 Toolbar
将滚动行为添加到您的 ListView
工具栏中的Popup主题是错误的
替换这个
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark"
进入这个
app:popupTheme="@style/AppTheme.PopupOverlay"
我的工具栏覆盖了列表视图。
Toolbar.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" />
View.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
替换为CoordinatorLayout
将父级
AppBarLayout
添加到Toolbar
将滚动行为添加到您的
ListView
工具栏中的Popup主题是错误的 替换这个
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark"
进入这个
app:popupTheme="@style/AppTheme.PopupOverlay"