Settings for toolbar and menu font styles

Source: Internet
Author: User

Toolbar font styles on Text Display toolbar fonts and icons on white
<name= "theme">@style/themeoverlay.appcompat.dark.actionbar  </Item>
Font size, color, etc. on toolbar
<Itemname= "Android:titletextappearance">@style/toolbarsubtitle</Item><!--ToolBar Font Configuration -<stylename= "Toolbartitleappearance"><Itemname= "Android:textsize">30sp</Item><!--<item name= "Android:textstyle" >normal</item> -<Itemname= "Android:textcolor">@color/gold</Item></style>
Toolbar title Word limitlimit by setting Maxems or maxlength to Titletextappearance
    <!--ToolBar Font Configuration -    <stylename= "Toolbartitleappearance">        <Itemname= "android:maxems">1</Item> Invalid        <Itemname= "android:maxlength">1</Item> Invalid    </style>

Observe that Titletextappearance does not have a style that can directly set the word limit

Use the code to get the TextView on toolbar and then set the Maxems
Mtoolbar.getviewtreeobserver (). Addongloballayoutlistener (NewViewtreeobserver.ongloballayoutlistener () {@Override Public voidOngloballayout () {View View= Mtoolbar.getchildat (0); if(View! =NULL&& ViewinstanceofTextView) {TextView title=(TextView) view; Title.setmaxems (1); Mtoolbar.getviewtreeobserver (). Removeongloballayoutlistener ( This); }            }        });
By customizing the Toolbar.xml to achieve

Http://stackoverflow.com/questions/28487312/how-to-change-the-toolbar-text-size-in-android

<Android.support.v7.widget.ToolbarAndroid:id= "@+id/toolbar"Android:layout_height= "Wrap_content"Android:layout_width= "Match_parent">    <TextViewAndroid:id= "@+id/toolbar_title"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "hahaha"android:textsize= "25SP"/></Android.support.v7.widget.Toolbar>

Empty the toolbar default title and limit the number of words

        Mtoolbar.settitle ("");
Mtextview.setmaxems (1)
Actionbar on menu Explicit font style

Reference http://www.crifan.com/android_menu_text_size_too_small/

@Override  Public Boolean   = Menu.add (Menu.none, Menu.first, 100, "search");  Item.setshowasaction (menuitem.show_as_action_always);  returnSuper. Oncreateoptionsmenu (menu);}

Change the style of the search word on menu by changing the actionmenutextappearance

<stylename= "Apptheme"Parent= "Theme.AppCompat.Light.NoActionBar"><Itemname= "Android:actionmenutextappearance">@style/menutextstyle</Item></style><stylename= "Menutextstyle"><Itemname= "Android:textcolor">@color/white</Item><Itemname= "Android:textsize">18sp</Item></style>

Settings for toolbar and menu font styles

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.