Android Question TabHost extra different color of current tab?

welu1805

Active Member
Licensed User
Longtime User
Hi all,

is it possible to set a different color to the current tab so the user can better see which tab he selected?

Lutz
 

DonManfred

Expert
Licensed User
Longtime User
setTabTextColorStateList (tabHost1 As TabHost, ColorStateListName As String)
Set a ColorStateList to be used for the text color of all tab indicators.
The ColorStateList must be defined in XML in your application Objects/res/drawable folder.
Color for selected and not selected tab state can be defined.
 
Upvote 0

welu1805

Active Member
Licensed User
Longtime User
setTabTextColorStateList (tabHost1 As TabHost, ColorStateListName As String)
Set a ColorStateList to be used for the text color of all tab indicators.
The ColorStateList must be defined in XML in your application Objects/res/drawable folder.
Color for selected and not selected tab state can be defined.
I do not want to set the TEXT color. I want to set the color of the tab.
 
Upvote 0

welu1805

Active Member
Licensed User
Longtime User
I found a solution by myself:

Sub Process_Globals
Dim anz As Int
End Sub

Sub Globals
Dim TabHost1 As TabHost
Dim TabHostExtras1 As TabHostExtras
Dim ColorDrawable1, ColorDrawable2 As ColorDrawable
End Sub

Sub Activity_Create
...
ColorDrawable1.Initialize(Colors.Blue, 10)
ColorDrawable2.Initialize(Colors.Red, 10)

anz = TabHostExtras1.GetTagWidget(TabHost1).TabCount
ColorTabs
End Sub

Sub ColorTabs
Dim i As Int
For i = 0 To anz - 1
Dim TabIndicator As Panel
TabIndicator = TabHostExtras1.GetTagWidget(TabHost1).GetChildTabViewAt(i)

If i = TabHost1.CurrentTab Then
TabIndicator.Background = ColorDrawable1
Else
TabIndicator.Background = ColorDrawable2
End If
Next
End Sub

Sub TabHost1_TabChanged
ColorTabs
...
End Sub
 
Upvote 0

Derek Jee

Active Member
Licensed User
Longtime User
Thank you..

This also helped me change the colours of all tabs based on my database values..
 
Upvote 0
Top