2016-03-10 20 views
1

我使用的是從GithubPerseiLayout,它除了片段的所有片段工作得很好,我用它FragmentTabHost在向下滾動不會顯示英仙座菜單:this menu won't be showen with scrolling down在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的滾動向下滾動的作品。

回答

0

我找到解決問題的一個非常奇怪的方式,但我不相信它的基礎上,我的編輯,我試圖在佈局上添加ListView,所以我的佈局變成這個樣子:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <ListView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
    </ListView> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="first tab !"/> 
</RelativeLayout> 

和砰!有效 ! 任何人都可以解釋爲什麼它與ListView? 我希望任何人都可以給我更合理的方式來解決問題!