I am trying to make a tabview in android that has icon alongwith background. But can’t set background of the tab.
java
intent = new Intent().setClass(this, mainActivity.class);
spec = tabHost.newTabSpec("main").setIndicator("Main", res.getDrawable(R.drawable.ic_tab_main)).setContent(intent);
tabHost.addTab(spec);
xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/cameraiconblack"
android:state_selected="true" />
<item android:drawable="@drawable/cameraiconwhite" />
</selector>
Provide this
Then in tab_unselected.xml write
& for tab_selected.xml
Now for back ground make layout file for image and textview or whatever u want
Now change your main tab file like this
put setTabs() method in your oncreate.
Now addTab method
I think i have put all codes required.Now enjoy