提交 8fdee614 编写于 作者: C chaychan

添加英文版文档

上级 d5725d90
[中文(Chinese)](https://github.com/chaychan/BottomBarLayout)
### 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:
### Demo
![](./intro_img/display1.gif)
#### Display unread, show red dot, display message
![](./intro_img/4.png)
### 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
<!--Default icon-->
<attr name="iconNormal" format="reference"/>
<!--Selected icon-->
<attr name="iconSelected" format="reference"/>
<!--Bottom text-->
<attr name="itemText" format="string"/>
<!--Bottom text size-->
<attr name="itemTextSize" format="dimension"/>
<!--Default bottom text color-->
<attr name="textColorNormal" format="color"/>
<!--Selected bottom text color-->
<attr name="textColorSelected" format="color"/>
<!--The top of the text and icon-->
<attr name="itemMarginTop" format="dimension"/>
<!--Whether to open the touch background effect-->
<attr name="openTouchBg" format="boolean"/>
<!--Set touch background-->
<attr name="touchDrawable" format="reference"/>
<!--Set the width of the icon-->
<attr name="iconWidth" format="dimension"/>
<!--Set the height of the icon-->
<attr name="iconHeight" format="dimension"/>
<!--Set the padding of BottomBarItem-->
<attr name="itemPadding" format="dimension"/>
<!--Set unread font size-->
<attr name="unreadTextSize" format="dimension"/>
<!--Set the message font size-->
<attr name="msgTextSize" format="dimension"/>
<!--Set the number of unread array thresholds greater than the threshold to be displayed as n + n as the set threshold-->
<attr name="unreadThreshold" format="integer"/>
#### Configuration in the layout file
In the xml file, configure BottomBarLayout to wrap the sub-item BottomBarItem
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<android.support.v4.view.ViewPager
android:id="@+id/vp_content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
></android.support.v4.view.ViewPager>
<com.chaychan.library.BottomBarLayout
android:id="@+id/bbl"
android:layout_width="match_parent"
android:layout_height="45dp"
android:orientation="horizontal"
android:gravity="center"
android:layout_gravity="center"
android:background="@color/tab_gb"
>
<com.chaychan.library.BottomBarItem
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
app:iconNormal="@mipmap/tab_home_normal"
app:iconSelected="@mipmap/tab_home_selected"
app:itemText="首页"
app:textColorNormal="@color/tab_normal_color"
app:textColorSelected="@color/tab_selected_color"
app:itemTextSize="8sp"
app:itemMarginTop="-5dp"
/>
<com.chaychan.library.BottomBarItem
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
app:iconNormal="@mipmap/tab_video_normal"
app:iconSelected="@mipmap/tab_video_selected"
app:itemText="视频"
app:textColorNormal="@color/tab_normal_color"
app:textColorSelected="@color/tab_selected_color"
app:itemTextSize="8sp"
app:itemMarginTop="-5dp"
/>
<com.chaychan.library.BottomBarItem
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
app:iconNormal="@mipmap/tab_micro_normal"
app:iconSelected="@mipmap/tab_micro_selected"
app:itemText="微头条"
app:textColorNormal="@color/tab_normal_color"
app:textColorSelected="@color/tab_selected_color"
app:itemTextSize="8sp"
app:itemMarginTop="-5dp"
/>
<com.chaychan.library.BottomBarItem
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
app:iconNormal="@mipmap/tab_me_normal"
app:iconSelected="@mipmap/tab_me_selected"
app:itemText="我的"
app:textColorNormal="@color/tab_normal_color"
app:textColorSelected="@color/tab_selected_color"
app:itemTextSize="8sp"
app:itemMarginTop="-5dp"
/>
</com.chaychan.library.BottomBarLayout>
</LinearLayout>
#### 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
#### 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
&emsp;&emsp; 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
#### **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:1.1.1' //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)
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:
[英文(English)](https://github.com/chaychan/BottomBarLayout/blob/master/README-en.md)
### 轻量级的底部导航栏
&emsp;&emsp;目前市场上的App,几乎都有底部页签导航栏,所以我们在开发的时候经常需要用到这个,虽然github上有不少已经封装好的底部导航栏的工具,例如bottombar,alphaIndicator(仿微信滑动渐变底部控件)等,但是这些控件由于功能太多,而且也没有给予详细的介绍文档,所以用起来不是特别容易,有时候我们仅仅只是想要一个简简单单的底部导航,但是又不想去自己在布局中搞一个个LinearLayout或者RadioGroup,然后切换页签的时候更换图标,让ViewPager跳转到对应的页面等一系列繁琐的操作,这时候,你可以使用BottomBarLayout,简简单单就可以实现以下效果:
![](./intro_img/display1.gif)
####显示未读数、提示小红点、提示消息
#### 显示未读数、提示小红点、提示消息
![](./intro_img/4.png)
......@@ -186,7 +188,7 @@
#### 显示未读数、提示小红点、提示消息
mBottomBarLayout.setUnread(0,20);//设置第一个页签的未读数为20
mBottomBarLayout.setUnread(1,101);//设置第二个页签的未读
mBottomBarLayout.setUnread(1,101);//设置第二个页签的未读
mBottomBarLayout.showNotify(2);//设置第三个页签显示提示的小红点
mBottomBarLayout.setMsg(3,"NEW");//设置第四个页签显示NEW提示文字
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册