Custom view inside HorizontalScrollView not scrolling

I have a custom view inside a HorizontalScrollView, like this:

<HorizontalScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fillViewport="true"
         >

        <com.mina.demo.customwidgets.MyCustomView
            android:layout_width="wrap_content"
            android:layout_height="50dp"
            />

    </HorizontalScrollView>

In the MyCustomView onDraw () method, I draw text and bitmap images.

the problem is that the width of the user view becomes larger than the width of the screen, and the wrapper of the horizontal scroll view does not scroll as if it were disabled.

what could be the reason for this?

+5
source share
1 answer

If yours is MyCustomViewalways greater than the width of the screen, then it is safe to set the width HorizontalScrollViewequal to its contents. Try the following:

<HorizontalScrollView
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:fillViewport="true"
     >

    <com.mina.demo.customwidgets.MyCustomView
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        />

</HorizontalScrollView>

, , HorizontalScrollView fill_parent. , , .

0

All Articles