ActionBar tabs set dynamic width according to screen width

后端 未结 3 1237
有刺的猬
有刺的猬 2020-12-18 13:57

I have 5 tabs in all. This is how I am adding them :

for (int i = 0; i < tabs.length; i++) {

                if (i == 0) {
                    actionBa         


        
3条回答
  •  -上瘾入骨i
    2020-12-18 14:37

    Tab view width is based on content/yourImage size, so to make tab view width smaller, we have to control the content/Image size. You can do this by putting ImageView inside FrameLayout, for example your customView can be:

    
    
    
       
    
        
    
        
    
    
    

    and custom style for tab:

    
    
    
    


    [SCREENSHOT]

    For FrameLayout size with 24dp: For <code>FrameLayout</code> size with <code>24dp</code>

    For FrameLayout size with 40dp For <code>FrameLayout</code> size with <code>40dp</code>

提交回复
热议问题