Q:

How to display a custom view in Android?

I am generating a custom View that contains a number of drawables that are added to the View dynamically. This means the View's size could be anything, and is likely to stretch off the screen. Where it does stretch off the screen I want scrolling to be enabled.
So far I have tried:

adding the custom view directly to my Activity - this displays the drawables ok, but with no scrolling
adding the custom view as a child to a ScrollView and setting the ScrollView as the content in the Activity - this doesn't display anything.

How do I generate a custom view of arbitrary size, display it and have scrolling where it is too big for the screen?

A:

Adding it to a ScrollView should be fine. Remember:

A ScrollView is a FrameLayout, meaning
  you should place one child in it
  containing the entire contents to
  scroll; this child may itself be a
  layout manager with a complex
  hierarchy of objects. A child that is
  often used is a LinearLayout in a
  vertical orientation, presenting a
  vertical array of top-level items that
  the user can scroll through.

To make sure your "custom view" is working fine, first try to add a LinearLayout to the ScrollView and then add drawables to the LinearLayout.

