A
A
ArturPendragonOfficial2021-04-20 13:06:07
Android
ArturPendragonOfficial, 2021-04-20 13:06:07

Why does the ScrollView leave a lot of unnecessary space when scrolling down?

At me the content should come to an end on the button. That is, the button is the last bottom element.
Since there is a lot of text, I had to use ScrollView. And when scrolling down, the button goes up and the empty space starts to go.
I tried to set the height of the scrollview wrap_content. Nothing has changed.

<androidx.core.widget.NestedScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:theme="@style/ThemeOverlay.Smoke.FullscreenContainer"
    tools:context=".LectureFragment"
    android:background="@color/dark_background">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:weightSum="100">

            <ImageView
                android:id="@+id/imageView"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:src="@drawable/day1"
                android:layout_weight="20"
                android:layout_marginEnd="@dimen/margin_regarding_the_parent"
                android:layout_marginStart="@dimen/margin_regarding_the_parent"
                android:layout_marginBottom="@dimen/margin_between_something"
                android:scaleType="centerInside"
                />

            <TextView
                android:id="@+id/textView"
                android:text="@string/text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginEnd="@dimen/margin_regarding_the_parent"
                android:layout_marginStart="@dimen/margin_regarding_the_parent"
                android:layout_weight="10"
                android:textColor="@color/white" />

            <com.google.android.material.button.MaterialButton
                android:text="@string/submit_lecture_rus"
                android:layout_width="match_parent"
                android:layout_height="@dimen/height_button"
                android:layout_marginEnd="@dimen/margin_regarding_the_parent"
                android:layout_marginStart="@dimen/margin_regarding_the_parent"
                android:layout_marginBottom="@dimen/margin_regarding_the_parent"
                android:backgroundTint="@color/coral"
                />

        </LinearLayout>

</androidx.core.widget.NestedScrollView>


607ea745579d6302489702.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Zagaevsky, 2021-04-20
@zagayevskiy

What's inside the scrollview (that is, its content) should have a wrap_content height.

G
gamess431, 2021-04-22
@gamess431

Maybe it's worth margin or padding (programmatically)?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question