繁体   English   中英

我需要将 ListView 锚定到约束布局的顶部、底部、左侧和右侧边缘

[英]I need to Anchored the ListView to the top, bottom, left, and right edges of the constraint layout

<ListView
        android:layout_width="100dp"
        android:layout_height="100dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        >

    </ListView>

这是我在 XML 文件中创建的列表视图。 请检查我是否正确实施了“将 ListView 锚定到约束布局的顶部、底部、左侧和右侧边缘。”

如果你想完全锚定约束布局,那么让你的 ListView 的高度和重量match_parent

你的 ListView 代码看起来像这样

<ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        >

    </ListView>

如果你想以内容大小显示你的 listView 那么你需要像下面这样设置你的身高和体重

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

铁杆尺寸使您的布局响应更少。 因此,如果您想让您的应用程序具有响应性,请不要使用硬核尺寸。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM