Skip to content

Commit

Permalink
整理依赖库版本;添加演示Apk
Browse files Browse the repository at this point in the history
  • Loading branch information
ccw committed Dec 13, 2018
1 parent fbe5a5c commit c3a361a
Show file tree
Hide file tree
Showing 15 changed files with 260 additions and 83 deletions.
86 changes: 63 additions & 23 deletions README-en.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
[中文(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:


#### **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.2.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)
Expand All @@ -11,6 +38,10 @@

![](./intro_img/4.png)

### 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
Expand Down Expand Up @@ -200,6 +231,38 @@ Find the corresponding ViewPager and BottomBarLayout, set Adapter for ViewPager,

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:
Expand Down Expand Up @@ -267,29 +330,6 @@ Drawable is written as follows:
app:notifyPointBg="@drawable/shape_notify_point"


#### **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.2' //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.


Expand Down
86 changes: 63 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,45 @@
[英文(English)](https://github.com/chaychan/BottomBarLayout/blob/master/README-en.md)

### 支持

如果觉得我的项目对你有所帮助的话,帮我点下**star** 吧,让更多人的人可以看到,谢谢!

### 轻量级的底部导航栏
&emsp;&emsp;目前市场上的App,几乎都有底部页签导航栏,所以我们在开发的时候经常需要用到这个,虽然github上有不少已经封装好的底部导航栏的工具,例如bottombar,alphaIndicator(仿微信滑动渐变底部控件)等,但是这些控件由于功能太多,而且也没有给予详细的介绍文档,所以用起来不是特别容易,有时候我们仅仅只是想要一个简简单单的底部导航,但是又不想去自己在布局中搞一个个LinearLayout或者RadioGroup,然后切换页签的时候更换图标,让ViewPager跳转到对应的页面等一系列繁琐的操作,这时候,你可以使用BottomBarLayout,简简单单就可以实现以下效果:


#### **导入方式**

在项目根目录下的build.gradle中的allprojects{}中,添加jitpack仓库地址,如下:

allprojects {
repositories {
jcenter()
maven { url 'https://jitpack.io' }//添加jitpack仓库地址
}
}

打开app的module中的build.gradle,在dependencies{}中,添加依赖,如下:

dependencies {
compile 'com.github.chaychan:BottomBarLayout:1.2.0' //建议使用最新版本
}


最新发布的版本可以查看

[https://github.com/chaychan/BottomBarLayout/releases](https://github.com/chaychan/BottomBarLayout/releases)

![](./intro_img/display1.gif)

#### 显示未读数、提示小红点、提示消息

![](./intro_img/4.png)

### V1.2.0版本更新说明 (2018-12-13)

- 支持动态添加、移除条目

### V1.1.2版本更新说明(2018-03-20)

- 添加修改未读数字体颜色和背景的属性
Expand Down Expand Up @@ -191,6 +222,38 @@

这样就实现底部导航栏功能了

#### 动态添加条目

for (int i = 0; i < mTitleIds.length; i++) {
//创建item
BottomBarItem item = createBottomBarItem(i);
mBottomBarLayout.addItem(item); //添加条目

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)

//还有很多属性,详情请查看Builder里面的方法
.create(mNormalIconIds[i], mSelectedIconIds[i], getString(mTitleIds[i]));
return item;
}

#### 移除条目

mBottomBarLayout.removeItem(0);

#### 开启滑动效果

页签之间的切换默认关闭了滑动效果,如果需要开启可以通过调用BottomBarLayout的setSmoothScroll()方法:
Expand Down Expand Up @@ -328,29 +391,6 @@ drawable的编写如下:



#### **导入方式**

在项目根目录下的build.gradle中的allprojects{}中,添加jitpack仓库地址,如下:

allprojects {
repositories {
jcenter()
maven { url 'https://jitpack.io' }//添加jitpack仓库地址
}
}

打开app的module中的build.gradle,在dependencies{}中,添加依赖,如下:

dependencies {
compile 'com.github.chaychan:BottomBarLayout:1.1.2' //建议使用最新版本
}


最新发布的版本可以查看

[https://github.com/chaychan/BottomBarLayout/releases](https://github.com/chaychan/BottomBarLayout/releases)


好了,到这里BottomBarLayout的介绍就到此为止了,之所以封装这个控件主要是为了方便开发,希望可以帮助到更多人,如果大家有什么想法或者意见不妨向我提出,我会不断完善BottomBarLayout的。


Expand Down
Binary file added apk/demo.apk
Binary file not shown.
11 changes: 10 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.compile_sdk_version = 27
ext.build_tools_version = "27.0.3"

ext.min_sdk_version = 16
ext.target_sdk_version = 27
ext.android_support_version = "27.1.1"

repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.android.tools.build:gradle:3.1.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -15,6 +23,7 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
}
}

Expand Down
30 changes: 20 additions & 10 deletions demo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
compileSdkVersion compile_sdk_version
buildToolsVersion build_tools_version
defaultConfig {
applicationId "com.chaychan.bottombarlayout"
minSdkVersion 16
targetSdkVersion 25
minSdkVersion min_sdk_version
targetSdkVersion target_sdk_version
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
appSign {
keyAlias KEY_ALIAS
keyPassword KEY_PASSWORD
storeFile file(KEY_FILE_PATH)
storePassword KEY_STORE_PASSWORD
}
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.appSign
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
api fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
testCompile 'junit:junit:4.12'
compile project(':library')
api "com.android.support:appcompat-v7:$android_support_version"
api 'com.android.support.constraint:constraint-layout:1.0.1'
testImplementation 'junit:junit:4.12'
api project(':library')
}
Binary file added demo/demo.jks
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void changeFragment(int currentPosition) {

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu);
getMenuInflater().inflate(R.menu.menu_dynamic, menu);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.FrameLayout;
Expand Down Expand Up @@ -137,4 +139,28 @@ private void cancelTabLoading(BottomBarItem bottomItem) {
animation.cancel();
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_demo, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
switch (id) {
case R.id.action_clear_unread:
mBottomBarLayout.setUnread(0, 0);
mBottomBarLayout.setUnread(1, 0);
break;
case R.id.action_clear_notify:
mBottomBarLayout.hideNotify(2);
break;
case R.id.action_clear_msg:
mBottomBarLayout.hideMsg(3);
break;
}
return super.onOptionsItemSelected(item);
}
}
Loading

0 comments on commit c3a361a

Please sign in to comment.