How to change the font size of tabhost in android

后端 未结 4 1094
盖世英雄少女心
盖世英雄少女心 2020-11-27 15:23

How can the font size of the tabs be changed? I extend TabActivity for the tabs.

4条回答
  •  一向
    一向 (楼主)
    2020-11-27 16:11

    Its not pretty but try this Dirty Fix :

    TabWidget tw = (TabWidget)tabHost.findViewById(android.R.id.tabs);
    View tabView = tw.getChildTabViewAt(0);
    TextView tv = (TextView)tabView.findViewById(android.R.id.title);
    tv.setTextSize(20);
    

    or

     //Do this to hack font size of title text
     LinearLayout ll = (LinearLayout) tabHost.getChildAt(0);
     TabWidget tw = (TabWidget) ll.getChildAt(0);
    
     // for changing the text size of first tab
     RelativeLayout rllf = (RelativeLayout) tw.getChildAt(0);
     TextView lf = (TextView) rllf.getChildAt(1);
     lf.setTextSize(21);
     lf.setPadding(0, 0, 0, 6);
    

提交回复
热议问题