androidtabsandroid-4.0-ice-cream-sandwichtabactivity

Android ICS displaying tabactivity tabs wrong


I have an application using TabActivity but it is being rendered incorrectly on ICS. Not really interested in ActionBar or Fragments as a solution since the tabs still otherwise work for my and others applications.

Here is what it looks like on all other versions of android (the desired look)

and here is what it looks like on ICS, incorrect.

here is my tabactivity tab code, what needs to change?

    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);

and here is one of my tab button layout 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>

Solution

  • It is tough to give you a definitive answer. For example, your cited R.layout.main_tabs_account layout does not include an ImageView, which the screenshot displays, suggesting that something is out of sync within your question.

    That being said, here's what I would try: