'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. Please check whether I correctly implemented "Anchored the ListView to the top, bottom, left, and right edges of the constraint layout. "



Solution 1:[1]

if you want full anchored with Constraint layout then make your ListView's Height & Weight match_parent

your ListView code look like this

<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

        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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1