Android Question TabHost extra different color of current tab?

welu1805

Active Member
Licensed 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
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.
 

welu1805

Active Member
Licensed 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.
 

welu1805

Active Member
Licensed 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
 

Derek Jee

Active Member
Licensed User
Thank you..

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