2

I have a ScrollView with a single custom view inside of it. It will not scroll. I can get it to scroll if I put in a textview in it. I've looked for a solution but I can't find why it won't scroll.

I assume I need to somehow notify the ScrollView when my Custom view draws. This code is from onDraw on the custom control.

 canvas.drawLine(0, 0, 2000, 2000, paint); canvas.drawLine(0, 200, 2000, 200, paint); canvas.drawLine(0, 300, 2000, 300, paint); canvas.drawLine(0, 400, 2000, 400, paint); canvas.drawLine(0, 500, 2000, 500, paint); canvas.drawLine(0, 600, 2000, 600, paint); canvas.drawLine(0, 700, 2000, 700, paint); canvas.drawLine(0, 800, 2000, 800, paint); canvas.drawLine(0, 900, 2000, 900, paint); canvas.drawLine(0, 1000, 2000, 1000, paint); canvas.drawLine(0, 1100, 2000, 1000, paint); 

This is the xml file

<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/button_scroll" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center_horizontal" android:fillViewport="true" > <SCEWidgetWarehouseView android:id="@+id/WarehouseView" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </HorizontalScrollView> 

1 Answer 1

3

The problem is most likely that you did not implement onMeasure(int, int) properly in your custom view. This method is used to tell the system how big your view is. This is especially important when using wrap_content.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, that was it. I figured it was something simple like this I was missing. Thanks.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.