使用 FragmentTabHost 在 PerseiLayout 中滚动
scrolling in PerseiLayout with FragmentTabHost
我正在使用来自 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 :
的 PerseiLayout
这是我的片段代码,其中包含 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>
Fragment1 的布局:
<?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 滚动时向下滚动有效。
我找到了一个很奇怪的方法来解决这个问题,但我不相信它,根据我的编辑,我试图在布局上添加一个 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
一起使用?
我希望任何人都可以给我更合理的解决问题的方法!
我正在使用来自 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 :
PerseiLayout
这是我的片段代码,其中包含 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>
Fragment1 的布局:
<?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 滚动时向下滚动有效。
我找到了一个很奇怪的方法来解决这个问题,但我不相信它,根据我的编辑,我试图在布局上添加一个 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
一起使用?
我希望任何人都可以给我更合理的解决问题的方法!