Reputation: 13545
I have a tabhost with ~ 5 tabs,and I would like to change the background of it . There is a background image of the tabs , one rectangle image of all tabs. When I add to tabhost . It does not work. How to fix it? Thanks
<android.support.v4.app.FragmentTabHost
android:id="@+id/tabhost"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal"
android:background="@drawable/tabBg"
/>
Upvotes: 1
Views: 279
Reputation:
Do like this...
tabhost
.getTabWidget()
.getChildAt(/*Index of the tab of which you want to change the background*/)
.setBackground(/*the background res you want to set */)
Upvotes: 1
Reputation: 13545
Finally got the solution
public void setTabColor(TabHost tabhost) {
for(int i=0;i<tabhost.getTabWidget().getChildCount();i++)
{
tabhost.getTabWidget().getChildAt(i).setBackground(res.getDrawable(R.drawable.share_tab_bg)); // selected
}
}
Upvotes: 0
Reputation: 11
Try this
spec = tabHost.newTabSpec("orders")
.setIndicator("Orders",res.getDrawable(R.drawable.flash_36))
.setContent(R.id.ordersLayout);
Upvotes: 0