Setting selected TAB with a small triangle below it

前端 未结 3 1474
逝去的感伤
逝去的感伤 2020-12-09 22:17

I want my tabs to show like in the image with small triangle below it.Is this possible ?If yes, then help me with some codes or documentation.

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-09 22:56

    I think, the following approach is the simplest one. You just need to setup the following drawable (actually, it's Android's default drawable for tabs) as a background of the tabs:

    
    
        
        
        
        
        
        
        
        
    
    

    where tab_press, tab_focus and tab_selected drawables would be png's (I'd prefer 9-patches) with down-arrow and transparent region near it. tab_unselected drawable wouldn't have this arrow, but still would have same transparent region. The only thing left to do is to specify negative bottom margin for your TabWidget. Its value is determined by the height of the arrow (do not forget to use density independent units):

    explanatory scheme

提交回复
热议问题