Android Bottomnavigationbar navigation Bar

Source: Internet
Author: User

Basic properties
Setactivecolor//Select the font color for itemSetinactivecolor//the color in item is not selectedSetbarbackgroundcolor//Background Colorsetmode (bottomnavigationbar.mode_fixed)//fill mode, unselected item displays text, no shift animationsetmode (bottomnavigationbar.mode_shifting)//shift mode, the unselected item does not display text, and the selected text is displayedSetbackgroundstyle (bottomnavigationbar.background_style_static)//no water ripple effect when clickedSetbackgroundstyle (bottomnavigationbar.background_style_ripple)//when clicked, there is a ripple effect, that is, the background color of the navigation bar is the color of the item that you set in the selected state .AddItem (NewBottomnavigationitem (R.mipmap.ic_launcher_round, mtitles[0])//Add a Bottomnavigationitem subkey, set the icon and textSetinactiveicon (contextcompat.getdrawable ( This, R.mipmap.ic_launcher))//Add a Change icon when selectedSetfirstselectedposition (0)//The item labeled 0 is selected by defaultSetbadgeitem ()//Add Badgeitem Taginitialise ()//drawn, to be placed at the end of the set

Settabselectedlistener Listener
Bottomnavigationbar.settabselectedlistener (NewBottomnavigationbar.ontabselectedlistener () {@Override Public voidOntabselected (intposition) {        //triggered when a selected state is obtainedToast.maketext (mainactivity. This, "currently selected" +position,toast.length_short). Show (); } @Override Public voidOntabunselected (intposition) {        //triggered when the loss of focus is not selectedToast.maketext (mainactivity. This,position+ "lost Focus", Toast.length_short). Show (); } @Override Public voidOntabreselected (intposition) {        //can't trigger, I'm a hen too    }});
Badgeitem Mark 1. Pentagram Mark
New Shapebadgeitem ()         // Background Color        // the location defaults to the top right        . Setanimationduration// animation duration        . sethideonselect (false)//  True disappears when status is selected, unchecked show          // Hide
2. Text Markers
New Textbadgeitem ()        . Setborderwidth (4)// text Size        . setgravity (gravity.top)//  the location defaults to top right        . Setbackgroundcolorresource (r.color.coloraccent)// background color        . Setanimationduration// animation time        . SetText ("3")        . Sethideonselect ( false) // true to disappear when state is selected, unchecked to show again        . Show ();
Official All.gif

View Source

Android Bottomnavigationbar navigation Bar

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.