The performance of Android custom Actionbar.tab objects

Source: Internet
Author: User



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>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.