Android Custom Toolbar/actionbar View left blank

Source: Internet
Author: User

After the recent customization of toolbar, it was found that the left side could not be fully populated, always left a little blank, and the workaround was found by viewing the style in the support package for the newly released V7.

View the parent of Wiget.AppCompat.Toolbar, as follows:

<style name= "Base.Widget.AppCompat.Toolbar" parent= "Android:widget" >      <item name= "titletextappearance "> @style/textappearance.widget.appcompat.toolbar.title</item>      <item name=" Subtitletextappearance "> @style/textappearance.widget.appcompat.toolbar.subtitle</item>      <item Name= "Android:minheight" >?attr/actionBarSize</item>      <item name= "Titlemargins" >4dp</item >      <item name= "maxbuttonheight" >56dp</item>      <item name= "Collapseicon" >?attr/ homeasupindicator</item>      <item name= "collapsecontentdescription" > @string/abc_toolbar_collapse_ description</item>      <item name= "Contentinsetstart" >16dp</item>  </style>
Where the Contentinsetstart attribute is the reason why the custom Actionbar cannot be fully populated.
Workaround:

The new style that is defined in Styles.xml inherits from Wiget.AppCompat.Toolbar as follows:
<style name= "Clubtoolbar" parent= "Widget.AppCompat.Toolbar" >          <item name= "Contentinsetstart" >0DP </item><!--Set this property to resolve a blank section--  </style>

Then rewrite the Toolbar property in your style.xml apptheme :

<!--Base Application theme. "Noactionbar" hides the original Actionbar Settings toolbar-    <style name= "Apptheme" parent= " Theme.AppCompat.Light.NoActionBar ">        //...        .. <item name= "Toolbarstyle" > @style/clubtoolbar</item>    </style>



Android Custom Toolbar/actionbar View left blank

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.