Recently wanted to modify the text font and color of the Actionbar.tab object
found that the interface provided by this object is very limited
and online search about Actionbar.tab results Most of the earlier use is not the case of Google provided Actionbar
So I studied it one day and found it. Use interface Setcustomview to customize Actionbar.tab objects
Get a Actionbar.tab object first by Actionbar.gettabat (int)
Then call Setcustomview to use the custom layout
Note that there is no object to produce layout, but to use the layout directly
Layout can be customized to set the text size background color
The back is the same as using the normal layout
Get a TextView and then set the text background and so on
ActionBar = Getsupportactionbar (); Actionbar.tab t = actionbar.gettabat (i); T.setcustomview (r.layout.tab_layout_1); TextView title = (TextView) T.getcustomview (). Findviewbyid (R.id.tab_title); Title.setbackgroundresource ( R.drawable.detail); Title.settext (SectionID);
<?xml version= "1.0" encoding= "Utf-8"? ><framelayout xmlns:android= "http://schemas.android.com/apk/res/ Android " android:layout_width=" match_parent " android:layout_height=" match_parent " > < TextView android:id= "@+id/tab_title" android:layout_width= "wrap_content" android:layout_height= " Wrap_content " android:layout_margintop=" 5DP " android:layout_gravity=" Center_vertical|center " Android:textcolor= "@android: Color/holo_blue_dark" android:textsize= "14SP"/></framelayout>