2012-01-05 37 views
0

我有一個使用TabActivity的應用程序,但它在ICS上呈現不正確。對ActionBar或Fragments作爲解決方案沒有真正的興趣,因爲選項卡仍然適用於我和其他應用程序。顯示Tabactivity選項卡的Android ICS錯誤

下面是它看起來像Android上的所有其他版本(所期望的樣子) http://i44.tinypic.com/fb9jya.png

,這裏是什麼樣子的ICS,不正確的。

http://i44.tinypic.com/35btjl2.png

這裏是我的tabactivity製表符碼,需要改變什麼?

intent = new Intent().setClass(this, HomeMenuGroup.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    spec = tabHost.newTabSpec("homeMenuGroup").setIndicator(li.inflate(R.layout.main_tabs_home, tabHost.getTabContentView(), false)) 
      .setContent(intent); 
    tabHost.addTab(spec); 

    // Do the same for the other tabs 
    intent = new Intent().setClass(this, BuyTicketsGroup.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    spec = tabHost.newTabSpec("buyTicketsGroup").setIndicator(li.inflate(R.layout.main_tabs_buy, tabHost.getTabContentView(), false)) 
      .setContent(intent); 
    tabHost.addTab(spec); 

    intent = new Intent().setClass(this, UseTicketsGroup.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    spec = tabHost.newTabSpec("useTicketsGroup").setIndicator(li.inflate(R.layout.main_tabs_use, tabHost.getTabContentView(), false)) 
      .setContent(intent); 
    tabHost.addTab(spec); 

    intent = new Intent().setClass(this, MyAccountGroup.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    spec = tabHost.newTabSpec("myAccountGroup").setIndicator(li.inflate(R.layout.main_tabs_account, tabHost.getTabContentView(), false)) 
      .setContent(intent); 
    tabHost.addTab(spec); 

,這裏是我的標籤按鈕的佈局XML R.layout.main_tabs_account

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  android:layout_width="wrap_content" android:layout_height="wrap_content"> 
<TextView android:background="@drawable/switcher_account" 
     android:layout_width="80dip" 
     android:layout_height="60dip"/> 
</LinearLayout> 

回答

2

這是很難給你一個明確的答案之一。例如,您引用的R.layout.main_tabs_account版式不包括屏幕截圖顯示的ImageView,這表明某些內容在您的問題中不同步。

話雖這麼說,這是我想嘗試:

  • TextView移動你的尺寸的LinearLayout。你的文本不應該是80x60的下降;你的標籤大概是。

  • 考慮發佈包含您的TabHostTabWidget的佈局,因爲這可能會提供更多線索。

  • 看一眼this project,我使用自定義標籤,看看我接近它有什麼可以幫助你。此項目在Android 4.0上正常工作。

+0

感謝您指出'main_tabs_content'。它是一個具有可繪製背景的文本視圖,具有狀態。我將看到刪除linearlayout並將textview更改爲imageview – CQM 2012-01-05 22:27:06

+0

的工作方式。感謝您的回覆,我只是在閱讀您的建議以及我想象中的錯誤。在其他2.x設備上測試,以確保我保持兼容性 – CQM 2012-01-05 22:42:39