简体   繁体   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>

This is the list view that I have created in the XML file.这是我在 XML 文件中创建的列表视图。 Please check whether I correctly implemented "Anchored the ListView to the top, bottom, left, and right edges of the constraint layout. "请检查我是否正确实施了“将 ListView 锚定到约束布局的顶部、底部、左侧和右侧边缘。”

if you want full anchored with Constraint layout then make your ListView's Height & Weight match_parent如果你想完全锚定约束布局,那么让你的 ListView 的高度和重量match_parent

your ListView code look like this你的 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>

and if you want to show your listView in content size then you need to make your height and weight like below如果你想以内容大小显示你的 listView 那么你需要像下面这样设置你的身高和体重

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

Hardcore size make your layout Responsive-less.铁杆尺寸使您的布局响应更少。 So, don't use hardcore size if you want to make your app responsive.因此,如果您想让您的应用程序具有响应性,请不要使用硬核尺寸。

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

相关问题 需要从图像的顶部、底部、右侧和左侧照亮 20 个像素,然后我需要比较像素值 - Need to illuminate 20-pixels from top, bottom, right and left of an image and then I need to compare pixel values 约束布局有空间底部和顶部 - Constraint layout has space bottom and top 在boxlayout中是否有“从上到下”和“从右到左”? - Is there any 'top to bottom' and 'right to left' in boxlayout? 左上/右下网格的算法? - Algorithm for a top left/bottom right grid? 边框布局定位在右下角(但不是右上角) - Border Layout Positioning on bottom right (but not top) corner 将图片居中对齐,右下和左下 - Align pictures top center, bottom right and bottom left 相对布局的问题:右上角的锚定元素 - Problem with relative layouts: anchored elements at the top right 您好,我想将卫星菜单从屏幕的右上角移到屏幕的左下角 - hello,I would like to move my satellite menu from top right corner to the bottom left corner of the screen 给定int顶部,底部,左侧和右侧的整数,我该如何横切2D数组? - How do I transverse a 2D array given an int top, bottom, left, and right? 如何限制可拖动区域? 它在顶部和左侧起作用,但在右侧和底部不起作用 - How do I limit draggable area? it functions on top and left side, but not on the right side and bottom
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM