Utilice este método y diseño para usar su propio diseño para la pestaña. Para eliminar el divisor, simplemente reemplace el gráfico de fondo 9patch con el suyo.
public static View prepareTabView(Context context, String text, Drawable background) {
View view = LayoutInflater.from(context).inflate(R.layout.fake_native_tab, null);
TextView tv = (TextView) view.findViewById(R.id.fakeNativeTabTextView);
tv.setText(text);
view.setBackgroundDrawable(background);
return view;
}
fake_native_tab.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fakeNativeTabLayout" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:gravity="center"
android:orientation="vertical" android:background="@drawable/default_tab_background">
<!--
You can even define an Icon here (dont forget to set a custom icon in your code for each Tab):
<ImageView android:id="@+id/fakeNativeTabImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:src="@drawable/icon" />
-->
<TextView android:id="@+id/fakeNativeTabTextView"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/tab_text_color" android:textSize="@dimen/text_size_tiny"
android:text="Tab" android:ellipsize="marquee" />
</LinearLayout>
Uso (dentro de su TabActivity
):
/* Create Tabs */
// reusable Tab Spec
TabHost.TabSpec spec;
Intent tabIntent;
tabHost = getTabHost();
Resources res = getResources();
// Tab 1:
tabIntent = new Intent().setClass(this, Favorite.class);
spec = tabHost.newTabSpec(TAB_SOMETAB).setIndicator(
prepareTabView(this, (String) getText(R.string.tab_favorite), res
.getDrawable(R.drawable.tab_favorite_background), 0)).setContent(tabIntent);
tabHost.addTab(spec);
// Tab 2:
tabIntent = new Intent().setClass(this, History.class);
spec = tabHost.newTabSpec(TAB_SOMEOTHERTAB).setIndicator(
prepareTabView(this, (String) getText(R.string.tab_history), res
.getDrawable(R.drawable.tab_favorite_background), 0)).setContent(tabIntent);
tabHost.addTab(spec);
gracias por dar respuesta y también quiero para eliminar la línea divisoria entre las dos pestañas. por favor dígame cómo quitar la línea divisora entre dos pestañas – Ramakrishna
es posible establecer el ancho y alto de pestañas programáticamente así que intente expandir el ancho y luego puede obtenerlo ... – Lavanya
Simplemente use un gráfico de fondo que no tenga un divisor línea en él. – Mannaz