Thursday, October 20, 2011

Android ScrollView and Horizontal Scrolling

Don't waste your time trying to make ScrollView scroll horizontally.  It doesn't.  And the API docs clearly say so. 

For horizontal scrolling, use HorizontalScrollView.

If you need both horizontal and vertical scrolling, like I did, it works to embed the two.  Looks like this:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillViewport="false"
    android:fadeScrollbars="true"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

<HorizontalScrollView 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    
>
    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">


No comments:

Post a Comment