2014-07-18 3 views
0

세 개의 탭으로 FragmentTabHost를 구현했습니다. 그들은 탭을 변경할 때 잘 작동합니다. 그러나 탭의 각 조각 내에서 내용이 화면 영역 밖으로 나옵니다.Fragment 안드로이드 내에서 Tabhost가 구현되었을 때 조각이 영역 밖으로 나가는가?

내 부모 조각 자바 코드 :

public class TestFragment extends Fragment implements OnTabChangeListener { 
    private FragmentTabHost mTabHost; 
    private FrameLayout realtabcontent; 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
      Bundle savedInstanceState) { 

     View rootView = inflater.inflate(R.layout.test_fragment, container, 
       false); 
     realtabcontent = (FrameLayout) rootView 
       .findViewById(R.id.realtabcontent); 
     mTabHost = (FragmentTabHost) rootView 
       .findViewById(android.R.id.tabhost); 
     // mTabHost.setup(getActivity(), getChildFragmentManager(), 
     // R.id.realtabcontent); 
     mTabHost.setup(getActivity(), getChildFragmentManager()); 
     mTabHost.setOnTabChangedListener(this); 
     mTabHost.addTab(
       mTabHost.newTabSpec("fragmentb").setIndicator("Fragment B"), 
       FragmentB.class, null); 
     mTabHost.addTab(
       mTabHost.newTabSpec("fragmentc").setIndicator("Fragment C"), 
       FragmentC.class, null); 
     mTabHost.addTab(
       mTabHost.newTabSpec("fragmentd").setIndicator("Fragment D"), 
       FragmentD.class, null); 

     return rootView; 
    } 

학부모 조각의 XML :

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.app.FragmentTabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <FrameLayout 
     android:id="@+id/realtabcontent" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

</android.support.v4.app.FragmentTabHost> 

아이 Content within fragment going on tab rather than white area available

다음

내 코드입니다 : 다음과 같이 것 같습니다 파편에는 지금 보통 textview가 포함된다.

답변

2

XML 조각 탭에서 FrameLayout을 실제로 관리 할 필요가 없습니다. 아래처럼 XML ID를 setup 메소드에 추가하면됩니다.

mTabHost.setup(getActivity(), getChildFragmentManager(),R.layout.test_fragment); 
+0

굉장합니다. 고마워 :) – virendrao

+0

당신도 이것에 나를 도울 수 있습니까 : http://stackoverflow.com/questions/24799458/viewflipper-not-scrolling-when-scrolling-vertically-android – virendrao

+0

미안 ViewFlipper에 대해 많이 모른다. 그리고 위의 답을 받아 들여 다른 사람들도 도울 수 있도록하십시오. –

관련 문제