2010-01-06 58 views
2

我有一个Activity,它有一个Scrollview作为顶级元素。里面还有一些其他视图,并且在某个时候有一个TabHost。您可以通过查看the screenshot获得更好的印象。 TabHost有三个选项卡,每个选项卡都有一个由Intent启动的另一个Activity。TabHost在ScrollView中:当点击一个Tab时总是向下滚动

除了一件事以外,一切正常。每当我点击一个标签,滚动视图就会自动向下滚动,你可以看到over here。 TabHost之后不在屏幕中。我只是不希望它向下滚动,但看不到问题所在。我在1.5和1.6设备和2.0仿真器上测试了相同的结果。

我TabHost的XML看起来是这样的:

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

有什么建议?

+0

这是一个老问题,但任何与类似问题斗争的人都可以在这里尝试解决方案:http://stackoverflow.com/a/10442368/56285 – Jonik 2015-04-16 21:27:51

回答

0

你可以尝试设置ActivityTabHost如滚动,而不是顶级Activity本身。