When I use views as tabSpec indicator the view is the same when a tab is selected or not.
Is there any way to use different views like when we use different drawable (selector) for the selected tab?
I already tried using the selector but it only allow to change the icon. What I want is the use a custom view and still be able to use different views for the different tab states.
Here is my code:
View profilInd = getLayoutInflater().inflate(R.layout.tabs_profil_layout, null);
Intent profilIntent = new Intent(this, MyProfilActivity.class);
tabHost.addTab(tabHost.newTabSpec("profil").setIndicator(profilInd).setContent(profilIntent));
The tabs_profil_layout layout is a simple LinearLayout with an ImageView and a TextView.
What you want to do is use a selector in your view/drawable which will change between the selected and not selected states.
This question covers some similar topics: Android : Customizing tabs on state : How do I make a selector a drawable
Essentially you will be making a drawable resource that looks something like this:
Which you will then assign to the tab.
You can learn more about selectors and Drawable here.