For this you should use custom tabs, here is a sample code:
tabHost= getTabHost(); tabHost.addTab(tabHost.newTabSpec("tab1").setContent(new Intent(this, Activity2.class)).setIndicator(prepareTabView("Names",R.drawable.icon)));
where prepareTabView is the method that inflates the view. Then overlay the view as follows:
private View prepareTabView(String text, int resId) { View view = LayoutInflater.from(this).inflate(R.layout.tabs, null); ImageView iv = (ImageView) view.findViewById(R.id.TabImageView); TextView tv = (TextView) view.findViewById(R.id.TabTextView); iv.setImageResource(resId); tv.setText(text); return view; }
If the XML tabs look like this:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:id="@+id/TabLayout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:padding="5dip"> <ImageView android:id="@+id/TabImageView" android:src="@drawable/icon" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <TextView android:id="@+id/TabTextView" android:text="Text" android:paddingTop="5dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/black" android:textAppearance="@style/TabTextViewStyle" /> </LinearLayout>
Then add your back color as you like.
source share