Search code examples
androidxmlhorizontalscrollview

Android HorizontalScrollView doesn't scroll


I have the following HorizontalScrollView with 2 custom views.

For some reason it doesn't scroll

<com.name.CustomObjects.HorizontalLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="10dp"
    android:fillViewport="true"
    android:scrollbars="horizontal" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <com.name.Views.AView
            android:id="@+id/aView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <com.name.Views.BView
            android:id="@+id/bView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </LinearLayout>

</com.name.CustomObjects.HorizontalLayout>

Solution

  • Is there any content in either AView or BView? Because both their width is set to wrap_content, it's possible the ScrollView doesn't stretch...?

    Have you extended the class ScrollView in your HorizontalLayout?

    It may also be possible your HorizontalLayout doesn't stretch because of fillViewPort="true"