Deven
Deven

Reputation: 741

ScrollView not able to scroll at all

I have looked through similar questions and not looking for generalize answers but rather want to know why my below code is not working. I am generating the rest of the child inside LinearLayout programmatically. The only issue is that it is not scrolling. Please find below the code for the bottom-most card.

<ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toBottomOf="@+id/card2"
        tools:layout_editor_absoluteX="1dp"
        android:layout_margin="15dp"
        android:background="@drawable/scrollview">

        <LinearLayout
            android:id="@+id/parentScroll"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" />
</ScrollView>

Please find below the screenshot how it looks like. The scroll view should allow me to scroll for remaining future days in the bottom-most card but it only shows what fits on screen with no scrolling.

in

Upvotes: 0

Views: 80

Answers (2)

Nik
Nik

Reputation: 2060

Try adding bottom constraint to scrollview app:layout_constraintBottom_toBottomOf="parent"and change android:layout_height="wrap_content" to android:layout_height="0dp"

Upvotes: 2

Opatile Kelobang
Opatile Kelobang

Reputation: 473

There is no resource in your view. The code should work if you try this:

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_constraintTop_toBottomOf="@+id/card2"
    tools:layout_editor_absoluteX="1dp"
    android:layout_margin="15dp"
    android:background="@drawable/scrollview">

    <LinearLayout
        android:id="@+id/parentScroll"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/long_string"  <-- Add a long string
        android:orientation="vertical" />
</ScrollView>

Add you string resource in res/values/strings.xml like this:

<?xml version="1.0" encoding="utf-8"?>
<resources>
   <string name="long_string">
      real really long text      <-- Add Text Here
   </string>
</resources>

Upvotes: 0

Related Questions