Listview Inside Constraint View Gets Clipped And Not Scrolling
I have a listview inside my ConstraintLayout and I read its supposed to automatically be scrollable, but the list just gets cut-off at the bottom with more items left to be display
Solution 1:
You need to close the chain, like so:
<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:layout_width="match_parent"android:layout_height="match_parent"><TextViewandroid:id="@+id/special_text_view"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginStart="8dp"android:layout_marginTop="8dp"android:text="Today is:"android:textColor="@android:color/white"android:textSize="24sp"android:visibility="gone"app:layout_constraintBottom_toTopOf="@id/date_text_view"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent" /><TextViewandroid:id="@+id/date_text_view"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="8dp"android:layout_marginStart="8dp"android:layout_marginTop="8dp"android:text="The date is:"android:textColor="@android:color/white"android:textSize="24sp"app:layout_constraintBottom_toTopOf="@id/oc_text_view"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@id/special_text_view" /><TextViewandroid:id="@+id/oc_text_view"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="8dp"android:layout_marginStart="8dp"android:layout_marginTop="8dp"android:text="The day of the omer is:"android:textColor="@android:color/white"android:textSize="24sp"android:visibility="gone"app:layout_constraintBottom_toTopOf="@id/list_view"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@id/date_text_view" /><ListViewandroid:id="@+id/list_view"android:layout_width="match_parent"android:layout_height="0dp"android:layout_marginBottom="24dp"android:layout_marginTop="24dp"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@id/oc_text_view"></ListView></android.support.constraint.ConstraintLayout>
Solution 2:
While using ConstraintLayout you have to add constraints for constraintTop, constraintRight, constraintBottom, constraintLeft or constraintStart and constraintEnd. Please constraint all your four sides of constrant layout(or use Constraint Start or End). Then only it works as expected
use below code in list view:
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
For Reference: https://developer.android.com/training/constraint-layout/index.htmlenter link description here
Solution 3:
Try This...
Here I'm populating 10 items in the ListView. See the attached result.
<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayoutxmlns: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:layout_width="match_parent"android:layout_height="match_parent"tools:context="com.silambarasan.test.MainActivity"
><TextViewandroid:id="@+id/special_text_view"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="8dp"android:layout_marginStart="8dp"android:layout_marginTop="8dp"android:text="Today is:"android:textColor="@android:color/black"android:textSize="24sp"android:visibility="visible"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent"
/><TextViewandroid:id="@+id/date_text_view"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginBottom="8dp"android:layout_marginLeft="8dp"android:layout_marginStart="8dp"android:layout_marginTop="8dp"android:text="The date is:"android:textColor="@android:color/black"android:textSize="24sp"app:layout_constraintBottom_toTopOf="@+id/oc_text_view"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@id/special_text_view"
/><TextViewandroid:id="@+id/oc_text_view"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="8dp"android:layout_marginStart="8dp"android:layout_marginTop="16dp"android:text="The day of the omer is:"android:textColor="@android:color/black"android:textSize="24sp"android:visibility="visible"app:layout_constraintBottom_toTopOf="@+id/guideline1"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintHorizontal_bias="0.47"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@id/date_text_view"
/><ListViewandroid:id="@+id/list_view"android:layout_width="match_parent"android:layout_height="0dp"android:layout_marginTop="8dp"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintHorizontal_bias="0.0"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="@+id/guideline1"app:layout_constraintVertical_bias="1.0"
></ListView><android.support.constraint.Guidelineandroid:id="@+id/guideline1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="horizontal"app:layout_constraintGuide_percent="0.3"
/></android.support.constraint.ConstraintLayout>
Result:
Solution 4:
With using the androidx.constraintlayout.widget.ConstraintLayout
, you can try this:
<?xml version="1.0" encoding="utf-8"?><androidx.constraintlayout.widget.ConstraintLayoutxmlns: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:layout_width="match_parent"android:layout_height="match_parent"
><TextViewandroid:id="@+id/special_text_view"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="8dp"android:layout_marginStart="8dp"android:layout_marginTop="8dp"android:text="Today is:"android:textColor="@android:color/black"android:textSize="24sp"android:visibility="visible"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent"
/><TextViewandroid:id="@+id/date_text_view"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginBottom="8dp"android:layout_marginLeft="8dp"android:layout_marginStart="8dp"android:layout_marginTop="8dp"android:text="The date is:"android:textColor="@android:color/black"android:textSize="24sp"app:layout_constraintBottom_toTopOf="@+id/oc_text_view"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@id/special_text_view"
/><TextViewandroid:id="@+id/oc_text_view"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="8dp"android:layout_marginStart="8dp"android:layout_marginTop="16dp"android:text="The day of the omer is:"android:textColor="@android:color/black"android:textSize="24sp"android:visibility="visible"app:layout_constraintBottom_toTopOf="@+id/guideline1"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintHorizontal_bias="0.47"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@id/date_text_view"
/><ListViewandroid:id="@+id/list_view"android:layout_width="match_parent"android:layout_height="0dp"android:layout_marginTop="8dp"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintHorizontal_bias="0.0"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="@+id/guideline1"app:layout_constraintVertical_bias="1.0"
></ListView><androidx.constraintlayout.widget.Guidelineandroid:id="@+id/guideline1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="horizontal"app:layout_constraintGuide_percent="0.3"
/></androidx.constraintlayout.widget.ConstraintLayout>
Post a Comment for "Listview Inside Constraint View Gets Clipped And Not Scrolling"