can you change Tabhostextra selected tab indicator text color

Mahares

Expert
Licensed User
Longtime User
Using the tabhostextra library, the selected tabhost tab indicator at the top changes to gray whenever selected, which makes it hard to tell which tab page is selected. Normally, it should be the other way around. When selected, it should be bold and heavy color. Is there a way to change the color of the tabhost indicator text?
Thank you very much
 

warwound

Expert
Licensed User
Longtime User
TabHostExtras has a setTabTextColorStateList.
You use this method to assign an XML based ColorStateList to the tab indicators:

B4X:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_selected="true"   
        android:color="#0000FF" />
    <item android:state_selected="false"   
        android:color="#FF0000" />
</selector>

Maybe the XML can be updated to also define background color as well as text color?

Martin.
 
Upvote 0

Gary Milne

Active Member
Licensed User
Longtime User
TabHostExtras has a setTabTextColorStateList.
You use this method to assign an XML based ColorStateList to the tab indicators:

B4X:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_selected="true"  
        android:color="#0000FF" />
    <item android:state_selected="false"  
        android:color="#FF0000" />
</selector>

Maybe the XML can be updated to also define background color as well as text color?

Martin.

What file do I have to edit with this information to make it work? AndroidManifest.xml or something else?
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
place the xml file as follows ...

B4X:
'tab_widget_text_colors.xml file located in  project/objects/res/drawable ... must be set to read only ! !
TabHostExtras1.setTabTextColorStateList(TabHost1, "tab_widget_text_colors")

see HERE ... post #55 by Warwound.
 
Upvote 0

Gary Milne

Active Member
Licensed User
Longtime User
Thank you. I did find it after further research but it's good to have that information here along with the solution. Pretty easy and effective once you connect the dots.
 
Upvote 0
Top