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);
}
有什麼建議?
這是一個老問題,但任何與類似問題鬥爭的人都可以在這裏嘗試解決方案:http://stackoverflow.com/a/10442368/56285 – Jonik 2015-04-16 21:27:51