I'm trying to make a TabHost on HoneyComb as if I was on 1.6+ but the fact is when I copy the code (which is the same for both HoneyComb and previous version), the TabHost do not match the screen width. I don't get it?
Using Halo theme on API 3.0 with the emulator.
Here's the 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>
And here is my Activity :
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);
}
}
Does anyone know why does TabHost behave like that with HoneyComb?
Thats normal behaviour and how it's planned by Google. The Tabs won't fill the whole Activity unless you write your own TabHost.