android - 我的列表视图显示在应用标签上。如何解决这个问题..?
问题描述
我创建了一个活动,我想在其中显示消息的收件箱。为此,我创建了布局。在该布局中,我的列表视图显示在应用标签上。请有人帮我解决这个问题..
我试图调整布局蓝图中的列表视图,但它只是从底部移动。
文件
<?xml version="1.0" encoding="utf-8"?><!-- Use DrawerLayout as root container for activity -->
<androidx.drawerlayout.widget.DrawerLayout 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:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:contentInsetEnd="0dp"
app:contentInsetStart="0dp"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
tools:ignore="RedundantNamespace"/>
<!-- Layout to contain contents of main body of screen (drawer will slide over this) -->
<ListView
android:id="@+id/sms_list_view"
android:layout_width="match_parent"
android:layout_height="766dp"/>
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<!-- Container for contents of drawer - use NavigationViewActivity to make configuration easier -->
<com.google.android.material.navigation.NavigationView
android:id="@+id/navigationView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:itemIconTint="@color/navigation_icon_color_state"
app:menu="@menu/drawer_items" />
</androidx.drawerlayout.widget.DrawerLayout>
预期的
Listview 出现在应用标签下方。
实际的
解决方案
- 我认为你可以在 CoordinatorLayout 之后使用相对布局所以它会安排子视图显示。
例子 :-
<?xml version="1.0" encoding="utf-8"?><!-- Use DrawerLayout as root container for activity -->
<androidx.drawerlayout.widget.DrawerLayout 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:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:contentInsetEnd="0dp"
app:contentInsetStart="0dp"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
tools:ignore="RedundantNamespace" />
<!-- Layout to contain contents of main body of screen (drawer will slide over this) -->
<ListView
android:id="@+id/sms_list_view"
android:layout_width="match_parent"
android:layout_height="766dp"
android:layout_below="@id/toolbar" />
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@id/toolbar"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<!-- Container for contents of drawer - use NavigationViewActivity to make configuration easier -->
<com.google.android.material.navigation.NavigationView
android:id="@+id/navigationView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/navigation" />
只需替换上面的布局它肯定会工作。
注意:-您可以删除您的 CoordinatorLayout,因为它在这里没用,直接尝试 Relativelayout。或任何其他布局,例如:- Linearlayout , ConstraintLayout 等...
推荐阅读
- multithreading - 如何在Queue中实现并发
- python - 需要从基于字符串的文本文件中查找动态变化的整数
- mongodb - 如何检查mongodb数据中是否存在字段
- .htaccess - 从根目录重定向到子目录后如何从子目录运行opencart
- docker - 使用 scp 在两个 docker 容器之间复制文件
- hyperledger-fabric - 在超级账本结构的 chaicode 中执行大量事务时超时到期
- c# - 如何使用 C# 使用 ALSA 在 Linux 中获取和设置音量?
- javascript - Accordion 的 Active Title 属性无法正常工作
- python - 如何将默认值从数据库传递到 wagtail 中的 mapfield 面板
- regex - Perl 正则表达式将多行转换为单行