How to add padding to a tabs label?

前端 未结 3 900
死守一世寂寞
死守一世寂寞 2020-12-20 04:30

I just started programming for android. I\'m using a tab based layout in my app. I would like to put some padding around the tab label so that it\'s not so close to the icon

3条回答
  •  不知归路
    2020-12-20 05:05

    just use this code

        TabWidget widget = mTabHost.getTabWidget();
        for (int i = 0; i < widget.getChildCount(); i++) {
    
            //adjust height
            widget.getChildAt(i).getLayoutParams().height =40;
    
           //adjust textview
            TextView tv = (TextView) widget.getChildAt(i).findViewById(android.R.id.title);
            if (tv == null) {
                continue;
            }           
            tv.setAllCaps(false);
            tv.setTextSize(15);
    
            //set padding
            tv.setPadding(10,5, 10, 5);
    
        }
    

提交回复
热议问题