[中文(Chinese)](https://github.com/chaychan/BottomBarLayout) ### Support If you feel that my project is helpful to you, please help me to click on the **star** and let more people see it. Thank you! ### Introduction   Currently, App on the market almost has a navigation bar at the bottom, so we often need to use this during development. Although there are many tools on the github packaged bottom navigation bar, such as bottombar, alphaIndicator Swipe gradient bottom controls etc., but these controls are not particularly easy to use due to too many functions and no detailed documentation. Sometimes we just want a simple bottom navigation, but we don't want to go One by one in the layout of the LinearLayout or RadioGroup, and then change the tab icon, let ViewPager jump to the corresponding page and a series of tedious operations, this time, you can use BottomBarLayout, simply can achieve the following effect: #### Apk [click to download](https://raw.githubusercontent.com/chaychan/BottomBarLayout/master/apk/demo.apk) or scan the QR code ![](./intro_img/download_qr.png) #### **How to import** Add the jitpack repository address in allprojects{} in build.gradle in the project root directory, as follows: allprojects { repositories { jcenter() maven { url 'https://jitpack.io' }//Add jitpack warehouse address } } Open the build.gradle in the app's module, add dependencies in dependencies {} as follows: dependencies { compile 'com.github.chaychan:BottomBarLayout:2.0.0' //It is recommended to use the latest version } The latest version can be viewed [https://github.com/chaychan/BottomBarLayout/releases](https://github.com/chaychan/BottomBarLayout/releases) ### Demo ![](./intro_img/display1.gif) #### Display unread, show red dot, display message ![](./intro_img/4.png) #### Support to use lottie ![](./intro_img/lottie.gif) ### V2.0.0版本更新说明 (2020-11-21) - Migrate to AndroidX - Support to use lottie ### V1.1.2 update instructions (2018-12-13) - Support for dynamically adding and removing item ### V1.1.2 update instructions(2018-03-20) - Add attributes to modify unread font colors and background - Add attributes to modify prompt text font colors and background - Add attributes to modify prompt point background ### V1.1.1 update instructions(2018-02-27) - Repair must be set up ViewPager problems, can be modified to set or not set; - Modify the click callback, callback more than a previousPosition (last page location) - Add two usage patterns ### V1.0.7 update instructions(2018-01-05) - Increase the threshold for unreadable attributes and set the properties for smooth transitions; - Remove oriention restrictions。 ### V1.0.6 update instructions(2017-12-19) - Add slide listener, callback onItemSelected () ### V1.0.4 update instructions(2017-10-10) - Increase the number of unread, tips red dot, suggesting the function of the message ### Usage #### Attribute introduction #### Configuration in the layout file In the xml file, configure BottomBarLayout to wrap the sub-item BottomBarItem #### Java file settings Find the corresponding ViewPager and BottomBarLayout, set Adapter for ViewPager, and then set the ViewPager for BottomBarLayout mVpContent.setAdapter(new MyAdapter(getSupportFragmentManager())); mBottomBarLayout.setViewPager(mVpContent); This realizes the bottom navigation bar function #### Add item dynamically for (int i = 0; i < mTitleIds.length; i++) { //create item BottomBarItem item = createBottomBarItem(i); mBottomBarLayout.addItem(item); //addItem TabFragment homeFragment = createFragment(mTitleIds[i]); mFragmentList.add(homeFragment); } private BottomBarItem createBottomBarItem(int i) { BottomBarItem item = new BottomBarItem.Builder(this) .titleTextSize(8) .titleNormalColor(R.color.tab_normal_color) .titleSelectedColor(R.color.tab_selected_color) // .openTouchBg(false) // .marginTop(5) // .itemPadding(5) // .unreadNumThreshold(99) // .unreadTextColor(R.color.white) //There are still many properties, please see the methods in the Builder for details. .create(mNormalIconIds[i], mSelectedIconIds[i], getString(mTitleIds[i])); return item; } #### Remove item mBottomBarLayout.removeItem(0); #### Turn on the slide effect Tab switch between the closure of the default sliding effect, if you need to open the setSmoothScroll () method can be called by calling BottomBarLayout: mBottomBarLayout.setSmoothScroll(true); You can also specify BottomBarLayout's smoothScroll property to be true in the layout file. The effect after opening is as follows: ![](./intro_img/display2.gif) #### Set the item selected listener mBottomBarLayout.setOnItemSelectedListener(new BottomBarLayout.OnItemSelectedListener() { @Override public void onItemSelected(final BottomBarItem bottomBarItem, int position) { //do something } }); #### Display unread, show red dot, display message mBottomBarLayout.setUnread(0,20);//Set the first tab's unread 20 mBottomBarLayout.setUnread(1,101);//Set the first tab's unread 101 mBottomBarLayout.showNotify(2);//The third page shows the tips of the little red dot mBottomBarLayout.setMsg(3,"NEW");//The fourth tab shows the NEW text When the setting of unread less than or equal to 0, the disappearance of small red dot will disappear; When the unread count is 1-99, the corresponding number is displayed. When unread more than 99, it shows 99+; #### Set unaware reading threshold    The unread threshold may specify the BottomBarItem's unreadThreshold property setting, which defaults to 99. For example, if app:unreadThreshold="999" is set, if the reading does not exceed this value, "999+" is displayed。 #### Hidden tips red dot, tips message mBottomBarLayout.hideNotify(2);//Hide the third page shows the tips of the little red dot mBottomBarLayout.hideMsg(3);//Hide the text displayed on the fourth tab #### Set unread font color app:unreadTextColor="@color/unreadTextColor" #### Set the unread background app:unreadTextBg="@drawable/shape_unread" Drawable is written as follows: #### Set prompt text font color, background app:msgTextColor="@color/msgTextColor" app:msgTextBg="@drawable/shape_msg" #### Set prompt point background app:notifyPointBg="@drawable/shape_notify_point" #### Set the name of lottie file app:lottieJson="home.json" "home.json" is stored in the assets directory. To set Lottie's width and height, use the iconWidth and iconHeight attributes Well, here's the introduction of BottomBarLayout stop here, the reason for the package this control is mainly for the convenience of development, hope to help more people, if you have any ideas or comments may wish to put forward to me, I will continue to improve BottomBarLayout of. #### Support and encouragement If you think my project is helpful to you, star! So I will be more motivated to improve this project: