1
我使用的是從GithubPerseiLayout
,它除了片段的所有片段工作得很好,我用它FragmentTabHost
在向下滾動不會顯示英仙座菜單:在PerseiLayout滾動與FragmentTabHost
這我的代碼片段含有TabHostFragment
:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.the_tabhost_fragment, container, false);
mTabHost = (FragmentTabHost)rootView.findViewById(android.R.id.tabhost);
mTabHost.setup(getActivity(), getChildFragmentManager(), R.id.realtabcontent);
View indicator = LayoutInflater.from(getActivity()).inflate(R.layout.tab_indicator, null);
setTabIcon(indicator,R.mipmap.icon1,"Tab1");
mTabHost.addTab(mTabHost.newTabSpec("fragmentb").setIndicator(indicator),
Fragment1.class, null);
indicator = LayoutInflater.from(getActivity()).inflate(R.layout.tab_indicator, null);
setTabIcon(indicator, R.mipmap.icon2, "Tab2");
mTabHost.addTab(mTabHost.newTabSpec("fragmentc").setIndicator(indicator),
Fragment2.class, null);
indicator = LayoutInflater.from(getActivity()).inflate(R.layout.tab_indicator, null);
setTabIcon(indicator, R.mipmap.icon3, "Tab3");
mTabHost.addTab(mTabHost.newTabSpec("fragmentd").setIndicator(indicator),
Fragment3.class, null);
return rootView;
}
the_tabhost_fragment.xml代碼:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.app.FragmentTabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="@+id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
而且片段1的佈局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="first tab !"/>
</LinearLayout>
編輯: 我不知道這是否可以幫助,但我意識到,當我開始從TextView的滾動向下滾動的作品。