I\'ve rolled my own custom view and can draw to the screen alright, but what I\'d really like to do is set the measuredHeigh of the screen to, say, 1000px and let the user s
If you are wanting the entire activity to be a ScrollView, then do something like this:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout android:id="@+id/scrollBody"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/string1" />
<TextView android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/string2" />
</LinearLayout>
</ScrollView>
Then the activity that uses this layout can look something like this:
public class ScrollingActivity extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.setContentView(R.layout.scroll_layout);
}
}
This assumes that the name of your xml file is scroll_layout.xml.
Just put your view in a ScrollView!
Note that the ScrollWiew should be the root node (here it's your LinearLayout)
If you want to do scrolling on your own, you can use a Scroller and a VelocityTracker while overriding the onTouchEvent
method of your custom view. To help you implement it I recommend looking through the Javadocs of these classes and taking a look at android widgets implementations that do scrolling like the NumberPicker.