Ulrich Scheller
Ulrich Scheller

Reputation: 11910

TabHost inside of a Scrollview: always scrolls down when a Tab is clicked

I have an Activity which has a Scrollview as the top level element. Inside there are some other Views and at some point there is a TabHost. You might get a better impression by looking at the screenshot. The TabHost has three tabs, each with another Activity that are launched by an Intent.

Everything is working fine except one thing. Whenever I click on a Tab, the Scrollview automatically scrolls down as you can see over here. The TabHost is out of the screen afterwards. I simply don't want it to scroll down, but can't see what the problem is. I tested on a 1.5 and 1.6 device and a 2.0 Emulator with the same results.

The xml of my TabHost looks like this:

    <TabHost
        android:id="@+id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content">
            </FrameLayout>
        </LinearLayout>
    </TabHost>

And this is the code for adding a Tab:

private void addTab(int descriptionRes, Class<?> destination, int flags) {
    String description = getString(descriptionRes);
    TabSpec spec = mTabHost.newTabSpec(description);
    spec.setIndicator(description);
    Intent i = new Intent(this, destination);
    i.setData(Uri.parse(member.getId())).setFlags(flags);
    spec.setContent(i);
    mTabHost.addTab(spec);
}

Any suggestions?

Upvotes: 2

Views: 2037

Answers (1)

Christopher Orr
Christopher Orr

Reputation: 111555

You could try setting the Activity inside the TabHost as scrollable, rather than the top-level Activity itself.

Upvotes: 0

Related Questions