Android Question TabHost extra different color of current tab?

Discussion in 'Android Questions' started by welu1805, Feb 26, 2015.

  1. welu1805

    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?

  2. DonManfred

    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.
  3. welu1805

    welu1805 Active Member Licensed User

    I do not want to set the TEXT color. I want to set the color of the tab.
  4. welu1805

    welu1805 Active Member Licensed User

    setTabGadientDrawable sets the backgroung on ALL TabIndicators. I would like another background for the current tab.
  5. welu1805

    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
    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
    TabIndicator.Background = ColorDrawable2
    End If
    End Sub

    Sub TabHost1_TabChanged
    End Sub
    jaraiza and RandomCoder like this.
  6. jaraiza

    jaraiza Active Member Licensed User

    THANKS! You gave me the idea how to change Tabs height without having to migrate everything from TabHost to TabHostExtras :) I'm really grateful :D
    Derek Jee likes this.
  7. Derek Jee

    Derek Jee Active Member Licensed User

    Thank you..

    This also helped me change the colours of all tabs based on my database values..
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice