2011-01-27 5 views
2

중첩 탭을 구현하는 응용 프로그램을 쓰고 있습니다. 두 세트의 탭은 꽤 많은 공간을 차지하기 때문에 일반적으로 내용의 특성 때문에 전체 내부 TabHost를 스크롤 가능한 구조에 배치하려고합니다. 외부 액티비티 FrameLayout, LinearLayout, 심지어 ViewFlipper의 tabcontent를 만들 수 있습니다. ScrollView를 만들려고 할 때 프로그램이 충돌합니다.안드로이드 - TabHost 내부 ScrollView

<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" /> 
     <ScrollView 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"/> 
    </LinearLayout> 

</TabHost> 

분명히 TabHost는 스크롤 할 수없는 프레임 안에 살고 싶어합니다. 전체를 엉망으로 만들지 않고이 문제를 해결할 수있는 방법이 있습니까?

답변

3

죄송합니다. 혼자서 알아 냈습니다. 해결책은 두 번째 TabHost를 자체 XML 파일 내의 ScrollView 안에 래핑하는 것입니다. 그건 잘 작동합니다.

외부 :

<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" /> 
     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"/> 
    </LinearLayout> 

</TabHost> 

내부 :

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <TabHost 
     android:id="@android:id/tabhost" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 

     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 
      <TabWidget 
       android:id="@android:id/tabs" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" /> 
      <ViewFlipper 
       android:id="@android:id/tabcontent" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent"/> 
     </LinearLayout> 

    </TabHost> 

</ScrollView> 
관련 문제