How to change Tab Indicator color programmatically

前端 未结 5 698
梦如初夏
梦如初夏 2021-01-19 19:04

I am new to Android, and before starting programming i found that now a days many of the apps are using Fragments, especially Tab with

5条回答
  •  旧巷少年郎
    2021-01-19 20:00

    The one and the best way to change selector color is to use Styles (I saw "Please Note", btw).

    In drawable folder create tab_selector.xml and do something like this:

    
        
        
    
    

    and then in your values/styles.xml I guess, do something like this:

    
    
    
    

    I'm possibly wrong with item name attribute in first style and parent attribute in second style. But in common it's will look like this.

    As you can see it is easy to do. All that you really have to do is make 9patch drawables, if you want to support different screens.

    Also you can look at Jake Wharton's ViewPagerIndicator that's is most flexible way to use any Navigation Mode.

提交回复
热议问题