Customizes the actionbar and removes the left blank. customizes the actionbar.

Source: Internet
Author: User

Customizes the actionbar and removes the left blank. customizes the actionbar.

You can customize the actionbar layout to change the actionbar style, which is simple, convenient, and elegant. However, you must note that there is a white space on the left under the high resolution, generally, at a resolution above 720, we can find that no matter how you change the layout file, there will always be a small blank.

Public void setActionBarLayout (int layoutId) {ActionBar actionBar = getActionBar (); if (null! = ActionBar) {// remove the blank actionBar. setTitle (""); actionBar. setDisplayShowHomeEnabled (false); actionBar. setDisplayShowCustomEnabled (true); LayoutInflater inflator = (LayoutInflater) this. getSystemService (Context. LAYOUT_INFLATER_SERVICE); View v = inflator. inflate (layoutId, null); ActionBar. layoutParams layout = new ActionBar. layoutParams (LayoutParams. MATCH_PARENT, LayoutParams. MATCH_PARENT); actionBar. setCustomView (v, layout );}
Call and input the layout at the corresponding location
SetActionBarLayout (R. layout. item_setting_actionbar );


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.