Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ScrollView doesn't show content

Can someone explain me why the scrollview doesnt show his child elements? I have a Alot of textviews inside a linearlayout vertical, that linearlayout is inside the scrollview...

But I dont see any scrollview neither the textviews..

Here is the XML Layout

<RelativeLayout 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" >

    <TextView
        android:id="@+id/description"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/scrollViewCheck"
        android:gravity="center"
        android:padding="10dip"
        android:text="Pick which items you want to count"
        android:textAppearance="?android:attr/textAppearanceMedium" >
    </TextView>

    <ScrollView
        android:id="@id/scrollViewCheck"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/bottomSettings"
        android:scrollbarFadeDuration="0" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:orientation="vertical" >

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Test"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Test"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Test"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Test"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Test"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Test"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Test"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Test"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:text="Test"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:text="Test"
                android:textAppearance="?android:attr/textAppearanceMedium" />
        </LinearLayout>
    </ScrollView>

    <RelativeLayout
        android:id="@id/bottomSettings"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/timeButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Choose Count Time" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/timeButton"
            android:orientation="horizontal" >

            <Button
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Back" />

            <Button
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Start" />
        </LinearLayout>
    </RelativeLayout>

</RelativeLayout>

Thanks in advance ;)

like image 997
TiagoM Avatar asked Dec 17 '25 04:12

TiagoM


2 Answers

The problem with the view has something to do with the RelativeLayout at the bottom. This should fix your issue. Replace the RelativeLayout at the bottom with this:

 <LinearLayout
        android:id="@+id/bottomSettings"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_alignParentBottom="true">

    <Button
            android:id="@+id/timeButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Choose Count Time" />

    <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/timeButton"
            android:orientation="horizontal" >

        <Button
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Back" />

        <Button
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Start" />

    </LinearLayout>

</LinearLayout>
like image 76
Ethan Avatar answered Dec 19 '25 18:12

Ethan


You are using a RelativeLayout as your root layout and are missing layout instructions like android:layout_below or android:layout_above.

That is why the elements are overlaying each other and you do not see your ScrollView.

Change your root layout to a LinearLayout with the attribute android:orientation="vertical" and you'll see all your widgets.

like image 23
jenzz Avatar answered Dec 19 '25 18:12

jenzz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!