I'm using PerseiLayout
from Github and it worked fine in all fragments except the fragment I'm using FragmentTabHost
on it where the scroll down won't show the Persei menu :
This my code for the fragment which contains the 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 code :
<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>
And the Fragment1's layout :
<?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>
Edit : I don't know if this can help but I realised that the scroll down works when I start scrolling from the TextView.
I found a very weird way to solve the problem but I'm not convinced with it, based on my edit, I tried to add a ListView
on the layout, so my layout became like this :
<?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>
And bang ! it worked !
Can anyone explain why it worked with a ListView
?
And I hope that anyone can give me more logical way to solve the problem !