Abp
Abp

Reputation: 153

constraint layout has extra space at bottom

I am implementing a view which uses constraint layout inside of scroll view. I am trying to align a view to the bottom of parent using app:layout_constraintBottom_toBottomOf="parent However there is extra white space below my view as you can see in the picture. The white space below blue color view. Can someone guide me on how to remove the extra white space at the bottom. Thanks in advance.

enter image description here

here is the code

<android.support.constraint.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:requiresFadingEdge="vertical"
        android:fadingEdgeLength="90dp"
        android:fadingEdge="vertical"
        android:fillViewport="true"
        >

        <android.support.constraint.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            >

            <ImageView
                android:id="@+id/image"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:minHeight="275dp"
                android:scaleType="center"
                android:src="@drawable/bubble_exclaimation"
                app:layout_constraintBottom_toTopOf="@id/content_layout"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <android.support.constraint.ConstraintLayout
                android:id="@+id/content_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/image"
                android:background="@android:color/holo_blue_dark"
                android:paddingBottom="15dp"
                >

                <TextView
                    android:id="@+id/title"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:text="@string/title"
                    android:textSize="17sp"
                    app:layout_constraintBottom_toTopOf="@+id/body"
                    app:layout_constraintLeft_toLeftOf="@+id/left_guideline"
                    app:layout_constraintRight_toLeftOf="@+id/right_guideline"
                    app:layout_constraintTop_toBottomOf="parent" />

                <TextView
                    android:id="@+id/body"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="13dp"
                    android:text="@string/content_small"
                    android:textSize="12sp"
                    app:layout_constraintLeft_toLeftOf="@+id/left_guideline"
                    app:layout_constraintRight_toLeftOf="@+id/right_guideline"
                    app:layout_constraintTop_toBottomOf="@+id/title" />

                <android.support.constraint.Guideline
                    android:id="@+id/left_guideline"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    app:layout_constraintGuide_percent="0.11" />

                <android.support.constraint.Guideline
                    android:id="@+id/right_guideline"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    app:layout_constraintGuide_percent="0.89" />
            </android.support.constraint.ConstraintLayout>

        </android.support.constraint.ConstraintLayout>


    </ScrollView>

    <View
        android:id="@+id/block"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="10dp"
        android:background="@android:color/holo_blue_dark"
        app:layout_constraintTop_toBottomOf="@id/scrollView"
        app:layout_constraintBottom_toBottomOf="parent"
        />

</android.support.constraint.ConstraintLayout>

Upvotes: 4

Views: 3591

Answers (1)

MJM
MJM

Reputation: 5301

Remove app:layout_constraintTop_toBottomOf="@+id/image" from android:id="@+id/content_layout"

 <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout xmlns: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">


        <ScrollView
            android:id="@+id/scrollView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fadingEdge="vertical"
            android:fadingEdgeLength="90dp"
            android:fillViewport="true"
            android:requiresFadingEdge="vertical">

            <android.support.constraint.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <ImageView
                    android:id="@+id/image"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:minHeight="275dp"
                    android:scaleType="center"
                    android:src="@drawable/bubble_exclaimation"
                    app:layout_constraintBottom_toTopOf="@id/content_layout"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintRight_toRightOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

                <android.support.constraint.ConstraintLayout
                    android:id="@+id/content_layout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@android:color/holo_blue_dark"
                    android:paddingBottom="15dp"
                    app:layout_constraintBottom_toBottomOf="parent">

                    <TextView
                        android:id="@+id/title"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:text="@string/title"
                        android:textSize="17sp"
                        app:layout_constraintBottom_toTopOf="@+id/body"
                        app:layout_constraintLeft_toLeftOf="@+id/left_guideline"
                        app:layout_constraintRight_toLeftOf="@+id/right_guideline"
                        app:layout_constraintTop_toBottomOf="parent" />

                    <TextView
                        android:id="@+id/body"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="13dp"
                        android:text="@string/content_small"
                        android:textSize="12sp"
                        app:layout_constraintLeft_toLeftOf="@+id/left_guideline"
                        app:layout_constraintRight_toLeftOf="@+id/right_guideline"
                        app:layout_constraintTop_toBottomOf="@+id/title" />

                    <android.support.constraint.Guideline
                        android:id="@+id/left_guideline"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        app:layout_constraintGuide_percent="0.11" />

                    <android.support.constraint.Guideline
                        android:id="@+id/right_guideline"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        app:layout_constraintGuide_percent="0.89" />
                </android.support.constraint.ConstraintLayout>

            </android.support.constraint.ConstraintLayout>


        </ScrollView>

        <View
            android:id="@+id/block"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_marginTop="10dp"
            android:background="@android:color/holo_blue_dark"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintTop_toBottomOf="@id/scrollView" />


    </android.support.constraint.ConstraintLayout>

enter image description here

Upvotes: 6

Related Questions