Мне нужно использовать TabHost
вместо ActionBarTabs
и чтобы они могли прокручиваться, я завернул свой TabWidget
в HorizontalScrollView
, но HorizontalScrollView
не прокручивается самв соответствии с ViewPager
.Я пытался использовать scrollTo и fullScroll несколькими способами, но это ничего не меняет.Что мне нужно сделать, чтобы это работало правильно?
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<HorizontalScrollView
android:id="@id/horizontalScrollView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="@null" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" />
</HorizontalScrollView>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
<android.support.v4.view.ViewPager
android:id="@id/viewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
@Override
public void onTabChanged(String tabId) {
int position = mTabHost.getCurrentTab();
mViewPager.setCurrentItem(position);
mHorizontalScrollView.scrollTo(position, 0);
}
@Override
public void onPageScrolled(int position, float positionOffset,
int positionOffsetPixels) {
mHorizontalScrollView.scrollTo(position, 0);
}