【问题标题】:How to make ListView to position under certain element?如何使 ListView 定位在某个元素下?
【发布时间】:2020-09-14 19:58:12
【问题描述】:

我正在尝试将 ListView 放在 Toolbar 下,但第一项设置在工具栏中,您能帮帮我吗?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/holo_blue_bright">
    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/cardview_light_background"
        android:minHeight="?attr/actionBarSize"
        >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="invites_fragment"
            android:textSize="30sp"
            android:layout_centerInParent="true">
        </TextView>
    </androidx.appcompat.widget.Toolbar>
    <ListView
        android:id="@+id/chatList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</RelativeLayout>

【问题讨论】:

    标签: java android xml listview layout


    【解决方案1】:

    只需在ListView中添加属性

    android:layout_below="@+id/toolbar”

    【讨论】:

    • 我确定只有 android:layout_above 属性,谢谢!但仍然第一个项目以错误的方式呈现,可能是因为我在预览中检查它 - 尚未填写列表所以我无法检查它模拟器。
    • 好吧,没关系,Android 工作室不得不考虑它,它可以工作。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多