Scrollview内部的TabHost:单击Tab时始终向下滚动 [英] TabHost inside of a Scrollview: always scrolls down when a Tab is clicked

查看:95
本文介绍了Scrollview内部的TabHost:单击Tab时始终向下滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Activity,它具有Scrollview作为顶层元素.里面有其他一些视图,并且在某个点上有一个TabHost.通过查看屏幕截图,您可能会得到更好的印象. TabHost具有三个选项卡,每个选项卡都有一个由Intent启动的另一个Activity.

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.

除一件事外,一切都正常.每当我单击选项卡时,滚动视图都会自动向下滚动,您可以在此处看到在此.之后,TabHost不在屏幕上.我只是不想让它向下滚动,但是看不到问题出在哪里.我在1.5和1.6设备以及2.0仿真器上进行了测试,结果相同.

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.

我的TabHost的xml看起来像这样:

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>

这是添加标签的代码:

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);
}

有什么建议吗?

推荐答案

您可以尝试将Activity inside 设置为可滚动,而不是将顶级Activity本身设置为可滚动

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

这篇关于Scrollview内部的TabHost:单击Tab时始终向下滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆