0

HoneyComb에서 TabHost를 만들려고합니다. 1.6+ 이상이지만 사실은 코드를 복사 할 때입니다 (HoneyComb과 이전 버전에서 동일 함). 버전), TabHost가 화면 너비와 일치하지 않습니다. 나는 그것을 얻지 못 하느냐?TabHost가 HoneyComb Android 3.0의 부모 너비와 일치하지 않습니다.

에뮬레이터에서 API 3.0의 Halo 테마를 사용합니다. 여기

은 XML입니다 : 여기

<?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"> 

    <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" 
     android:padding="5dp" /> 

</TabHost> 

그리고 내 활동은 다음과 같습니다

package org.agetac; 

import android.app.TabActivity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.widget.TabHost; 

public class TabsActivity extends TabActivity { 

    private static final String TAB_SITAC = "tab_sitac"; 
    private static final String TAB_SOEI = "tab_soei"; 
    private static final String TAB_MOYEN = "tab_moyen"; 
    private static final String TAB_TAB4 = "tab_tab4"; 
    private static final String TAB_TAB5 = "tab_tab5"; 


    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.tabs); 

     TabHost tHost = getTabHost(); 
     TabHost.TabSpec spec; 
     Intent tabIntent; 


     // Initialize a TabSpec for each tab and add it to the TabHost 
     tabIntent = new Intent().setClass(this, SITACActivity.class); 
     spec = tHost.newTabSpec(TAB_SITAC).setIndicator(getString(R.string.sitac), 
          getResources().getDrawable(R.drawable.ic_tab_sitac)) 
         .setContent(tabIntent); 
     tHost.addTab(spec); 

     tabIntent = new Intent().setClass(this, SOEIActivity.class); 
     spec = tHost.newTabSpec(TAB_SOEI).setIndicator(getString(R.string.soei), 
       getResources().getDrawable(R.drawable.ic_tab_soei)) 
      .setContent(tabIntent); 
     tHost.addTab(spec); 

     tabIntent = new Intent().setClass(this, MoyenActivity.class); 
     spec = tHost.newTabSpec(TAB_MOYEN).setIndicator(getString(R.string.moyen), 
       getResources().getDrawable(R.drawable.ic_tab_moyen)) 
      .setContent(tabIntent); 
     tHost.addTab(spec); 

     tabIntent = new Intent().setClass(this, Tab4Activity.class); 
     spec = tHost.newTabSpec(TAB_TAB4).setIndicator(getString(R.string.tab4), 
       getResources().getDrawable(R.drawable.ic_tab_tab4)) 
      .setContent(tabIntent); 
     tHost.addTab(spec); 

     tabIntent = new Intent().setClass(this, Tab5Activity.class); 
     spec = tHost.newTabSpec(TAB_TAB5).setIndicator(getString(R.string.tab5), 
       getResources().getDrawable(R.drawable.ic_tab_tab5)) 
      .setContent(tabIntent); 
     tHost.addTab(spec); 

     tHost.setCurrentTab(0); 
    } 
} 

사람이 벌집처럼 행동 TabHost 않는 이유를 알고 있나요?

+0

그건 타블렛 에뮬레이터에서 얻은 것입니다. [스크린 샷] (http://imageshack.us/photo/my-images/849/capturedu20111117135437.png) – Leiko

답변

0

정상적인 작동 및 Google에서 계획 한 내용입니다. TabHost를 직접 작성하지 않으면 탭이 전체 활동을 채우지 않습니다.