2011-11-22 5 views
0

TabLayout을 사용하여 응용 프로그램을 만들고 인 텐트를 사용하여 다른 클래스를로드 할 때 디스플레이에 문제가 있습니다.Android 탭 의도, 탭을 통한 레이아웃 자르기

나는이 방법을 사용하여 만드는 시도는 여기에서 볼 수있는 안드로이드 개발 가이드에 설명

http://developer.android.com/resources/tutorials/views/hello-tabwidget.html

그러나 나는 데 문제는 내가 아닌 응용 프로그램의 하단의 탭을 원하는이며, 내가 한 정상. 문제는 전체 애플리케이션을 볼 때 화면에 충분한 공간이 없기 때문에 새 탭을 클릭하고 레이아웃을로드 할 때 탭을 바로 통과한다는 것입니다. ScrollView를 추가하려고했지만 작동하지 않는 것 같습니다.

화면을로드 할 때이를 수정하는 방법에 대한 제안 사항은 내 탭이 항상 아래쪽에 나타나고 내 탭을 통해 내 레이아웃 클립이없는 페이지를 위아래로 스크롤 할 수 있습니다.

어떤 도움이 많이 내 main.xml에 대한

코드

을 감상 할 수있다 또한

<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" android:background="#92c223"> 

<LinearLayout android:orientation="vertical" 
    android:layout_width="fill_parent" android:layout_height="fill_parent" 
    android:padding="5dp"> 

    <FrameLayout android:id="@android:id/tabcontent" 
     android:layout_width="fill_parent" android:layout_height="fill_parent" 
     android:padding="5dp" /> 

</LinearLayout> 

<TabWidget android:id="@android:id/tabs" 
    android:layout_width="fill_parent" android:layout_height="wrap_content" 
    android:layout_gravity="bottom" /> 
</TabHost> 

의 I는 자바 탭 사이를 교환하는 데 사용되는 코드

intent = new Intent().setClass(this, tag.class); 
    spec = tabHost.newTabSpec("tag1") 
      .setIndicator("tag1", res.getDrawable(R.drawable.icon)) 
      .setContent(intent); 
    tabHost.addTab(spec); 

    intent = new Intent().setClass(this, tag2.class); 
    spec = tabHost.newTabSpec("tag2") 
      .setIndicator("tag2", res.getDrawable(R.drawable.icon2)) 
      .setContent(intent); 
    tabHost.addTab(spec); 

답변

1

이 시도입니다

<?xml version="1.0" encoding="utf-8"?> 
<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" 
     android:padding="5dp"> 

     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:padding="5dp" 
      android:layout_weight="1"/> 

     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0"/> 

    </LinearLayout> 

</TabHost> 

차이점은 FrameLayout에 있고, 높이는 wrap_content로 설정되어 있습니다. 여기서 너는 fill_parent로 설정됩니다. 또한 그는 FrameLayout에 layout_weight = 1을 적용하고 TabWidget에는 layout_weight = 0을 적용합니다.

취지 : here.

+0

고마워, 코드를 추가 한 다음 ScrollLayout을 추가하여 완벽하게 작동합니다. 건배 : D – AdamM