简体   繁体   中英

Scroll view does not work

I have a scroll view that I fill dynamicly in my code. I expect if I put too much content to the parant view that the view becomes scrollable. This does not work.

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true">

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layout_centerHorizontal="true"
            android:id="@+id/layoutScoreBoardHeader"
            android:layout_marginTop="15dp">

        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/layoutScoreBoard"
            android:orientation="horizontal"
            android:layout_centerHorizontal="true"
            android:layout_below="@id/layoutScoreBoardHeader">

        </LinearLayout>

    </RelativeLayout>
</ScrollView>

Bad layout structure. RelativeLayout should wrap_content. In your case it will be same size as initial ScrollView and it will ignore child size.

I have it. Did not know that there is a special view like horizontal scroll view. But thank you guys for your feedback!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM