一款强大的 Android 底部导航

   2016-11-22 0
核心提示::blush: JPTabBar:blush:阅读中文文档请点击这里 ScreenShots: Main functions and features:More Animation effects of multiple Tab switchingImplements the effect of the middle button of the bottom navigationImplements the kind of WeChat sliding

:blush: JPTabBar :blush:

阅读中文文档请点击这里

ScreenShots:

Main functions and features:

  • More Animation effects of multiple Tab switching

  • Implements the effect of the middle button of the bottom navigation

  • Implements the kind of WeChat sliding navigation of the bottom gradient effect, with the change of the sliding distance

  • Implements the red mark on the TabBar, and can drag

  • The powerful BadgeView function, intelligent judgment digital hiding and cross-border display, two display modes。

  • Provide listening to the click event, middle click and badge is dragged away the interface

  • Reference annotation method, construction TabBarItem

Usage:

1.Introducing Gradle dependency

repositories {
        jcenter()
    }

    dependencies{
        compile 'com.jpeng:JPTabBar:1.1.2'
    }

2.Add JPTabBar to your main interface layout

<com.jpeng.jptabbar.JPTabBar
        android:id="@+id/tabbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#fff"
        jp:TabHeight="56dp"
        jp:BadgeDraggable="true"
        jp:TabAnimate="Jump"
        jp:BadgePadding="4dp"
        jp:BadgeMargin="5dp"
        jp:BadgeTextSize="10dp"
        />

3.In your main interface using an array of variables to declare an array of variables, the internal reflection to generate TabItem, attention is: Titles and NorIcons are required, the length of each array should be consistent

@Titles
    private static final String[] mTitles = {"页面一","页面二","页面三","页面四"};

    @SeleIcons
    private static final int[] mSeleIcons = {R.mipmap.tab1_selected,R.mipmap.tab2_selected,R.mipmap.tab3_selected,R.mipmap.tab4_selected};

    @NorIcons
    private static final int[] mNormalIcons = {R.mipmap.tab1_normal, R.mipmap.tab2_normal, R.mipmap.tab3_normal, R.mipmap.tab4_normal};

4.After above, the layout of the TabBar basically has been built. If you want to achieve Wechat kind of gradual change as there are automatically ViewPager to change the function of the page, only in the oncreate Activity method, adding a line of code:

//The parameters must be extends ViewPager
    mTabbar.setContainer(mPager);

5.The project has provided many animation,If you want to Custom your Animation,You can setCustomAnimate,Duclipte of examples:

mTabbar.setCustomAnimate(new Animatable() {
                /**
                 * When you Tab Pager,The method will be called
                 * @param target IconView in the iconview
                 * @param Duration your animation time
                 */
                @Override
                public void playAnimate(View target, int Duration) {
                    ViewHelper.setPivotX(target,target.getLayoutParams().width/2);
                    ViewHelper.setPivotY(target,target.getLayoutParams().height/2);

                    AnimatorSet set = new AnimatorSet();
                    set.playTogether(
                            ObjectAnimator.ofFloat(target,"scaleX",0.2f,1f).setDuration(Duration),
                            ObjectAnimator.ofFloat(target,"scaleY",0.2f,1f).setDuration(Duration),
                            ObjectAnimator.ofFloat(target,"alpha",0.3f,1f).setDuration(Duration)
                    );

                    set.start();
                }

                /**
                 * The explain of the Method
                 * When you touch in the ViewPager by User,The method will be called back
                 * @param target The same in top
                 * @param offset Range value 0f-1f
                 */
                @Override
                public void onPageAnimate(View target, float offset) {
                    ViewHelper.setScaleX(target,1+offset*0.2f);
                    ViewHelper.setScaleY(target,1+offset*0.2f);
                }

                /**
                 * return true can make onPageAnimate method called
                 * @return
                 */
                @Override
                public boolean isNeedPageAnimate() {
                    return true;
                }
            });

Method and node description:

The Main Method Of JPTabBar:

/**
     * Set custom Tab toggle animation
     */
    public void setCustomAnimate(Animatable customAnimate);


     /**
     * Show the BadgeView With Text
     */
    public void ShowBadge(int position,String text);

    /**
     * Hide the OVAL Badge
     */
    public void HideBadge(int position);

    /**
     * Switch Tab page, whether with animation
     */
    public void setSelectTab(int index, boolean animated);

    /**
     * Set the Observer of the Click Tab Event
     */
    public void setTabListener(OnTabSelectListener listener);

    /**
     * set the CallBack of the Badge Dragging Dismiss
     */
    public void setDismissListener(BadgeDismissListener listener);

Attribute Explain:

Attribute Name Attribute Explain Parameter Type Default Value
TabHeight TabBar height, will cover the settings of layout_height dimension 56dp
TabNormalColor Font and icon of the normal color color 0xffAEAEAE(Gray)
TabSelectColor Font and icon of the selected color color 0xff59D9B9(Cyan)
TabTextSize the textsize of the bottom text dimension 14sp
TabIconSize the icon size of the tab dimension 24dp
TabIconFilter Set the icon change by the font color boolean true
TabMargin Set the icon distance above and below the distance from the text dimension 8dp
TabSelectBg Set the TabItem Selected bg color transparent
TabAnimate The animate type of the Tab Switch enum Scale
TabMiddleIcon The middle Icon of the tab drawable
BadgeColor The background of the badgeView color #f00(RED)
BadgeDraggable Can drag on the badge touched by user boolean false
BadgePadding The background expansion distance of the badge dimension 4dp
BadgeTextSize The textSize of the Badge dimension 11dp
BadgeMargin The badge right margin in the TabBar dimension 9dp

Matters needing attention

1.If you have given setContainer TabBar, do not setOnPageChangeListener to ViewPager

/**
    *If you already have the TabBar set up the container, 
    *and then call this method,
    *the kind of WeChat that drag the gradient effect and automatically switch the page will be invalid
    *If you want to listen to the page to change the event, you can use the TabListener
   */
  mPager.setOnPageChangeListener(this);

2.If you want to achieve the middle of the button, you must set the android:clipChildren= "false" to the parent node at the top of the main interface, otherwise it will be covered.

<?xml version="1.0" encoding="utf-8"?>
  <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:jp="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipChildren="false"
    android:gravity="bottom"
    android:orientation="vertical"
    >

Update Log

V1.0.4

  • Reverse the BadgePosition show error
  • Reverse the background covered by the TabItem Bg
  • Reverse the Default value error

V1.0.5

  • Reverse the BadgeView cannot move to LeftTop
  • Titles annotaion support int
  • Remove BadgeModes annotation,Enhance the flexibility of the use of badges,Update the TabBar method
  • Add the TabSelectBg attribute,used to set the selected item bg

V1.1.0

  • Reverse the Rending problem in the XML
  • Reverse the BUG of CLick Tab Event CallBack twice.
  • Add the OnPageAnimate Method in interface,Enhance the flexibility of animation

V1.1.2

  • Add the Bouncing of the Animation
  • Reverse don't click when have no Pager in the Adapter

Hope

If you think this project is fast and useful, help, don't forget to click on the upper right corner of the star, because I want to challenge the BAT school recruit in the next year。

The world's strong programmer code process will inevitably appear BUG, if the user found BUG, you can contact me or directly issue, thank you!

About Me

A college student, is still in the study of various techniques...

QQ:83508440

E-mail: 83508440@qq.com

License

Copyright 2016 [JPeng]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
 
标签: 安卓开发
反对 0举报 0 评论 0
 

免责声明:本文仅代表作者个人观点,与乐学笔记(本网)无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
    本网站有部分内容均转载自其它媒体,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责,若因作品内容、知识产权、版权和其他问题,请及时提供相关证明等材料并与我们留言联系,本网站将在规定时间内给予删除等相关处理.

  • 安卓中通知功能的具体实现
    安卓中通知功能的具体实现
    通知[Notification]是Android中比较有特色的功能,当某个应用程序希望给用户发出一些提示信息,而该应用程序又不在前台运行时,就可以借助通知实现。使用通知的步骤1、需要一个NotificationManager来获得NotificationManager manager = (NotificationManager
    02-05 安卓开发
  • Android view系统分析-setContentView
    Android view系统分析-setContentView
    第一天上班,列了一下今年要学习的东西。主要就是深入学习Android相关的系统源代码,夯实基础。对于学习Android系统源代码,也没什么大概,就从我们平常使用最基础的东西学起,也就是从view这个切入点开始学习Android的源码,在没分析源码之前,我们有的时候
    02-05 安卓开发
  • 如何进行网络视频截图/获取视频的缩略图
    如何进行网络视频截图/获取视频的缩略图
    小编导读:获取视频的缩略图,截图正在播放的视频某一帧,是在音视频开发中,常遇到的问题。本文是主要用于点播中截图视频,同时还可以获取点播视频的缩略图进行显示,留下一个问题,如下图所示, 如果要获取直播中节目视频缩略图,该怎么做呢?(ps:直播是直
  • Android NDK 层发起 HTTP 请求的问题及解决
    Android NDK 层发起 HTTP 请求的问题及解决
    前言新的一年,大家新年快乐~~鸡年大吉!本次给大家带来何老师的最新文章~虽然何老师还在过节,但依然放心不下广大开发者,在此佳节还未结束之际,给大家带来最新的技术分享~ 事件的起因不说了,总之是需要实现一个 NDK 层的网络请求。为了多端适用,还是选择
  • Android插件化(六): OpenAtlasの改写aapt以防止资源ID冲突
    Android插件化(六): OpenAtlasの改写aapt以防
    引言Android应用程序的编译中,负责资源打包的是aapt,如果不对打包后的资源ID进行控制,就会导致插件中的资源ID冲突。所以,我们需要改写aapt的源码,以达到通过某种方式传递资源ID的Package ID,通过aapt打包时获取到这个Package ID并且应用才插件资源的命名
    02-05 安卓开发
  • Android架构(一)MVP架构在Android中的实践
    Android架构(一)MVP架构在Android中的实践
    为什么要重视程序的架构设计 对程序进行架构设计的原因,归根结底是为了 提高生产力 。通过设计是程序模块化,做到模块内部的 高聚合 和模块之间的 低耦合 (如依赖注入就是低耦合的集中体现)。 这样做的好处是使得程序开发过程中,开发人员主需要专注于一点,
    02-05 安卓开发
  • 安卓逆向系列教程 4.2 分析锁机软件
    安卓逆向系列教程 4.2 分析锁机软件
    安卓逆向系列教程 4.2 分析锁机软件 作者: 飞龙 这个教程中我们要分析一个锁机软件。像这种软件都比较简单,完全可以顺着入口看下去,但我这里还是用关键点来定位。首先这个软件的截图是这样,进入这个界面之后,除非退出模拟器,否则没办法回到桌面。上面那
    02-05 安卓开发
  • Android插件化(二):OpenAtlas插件安装过程分析
    Android插件化(二):OpenAtlas插件安装过程分析
    在前一篇博客 Android插件化(一):OpenAtlas架构以及实现原理概要 中,我们对应Android插件化存在的问题,实现原理,以及目前的实现方案进行了简单的叙述。从这篇开始,我们要深入到OpenAtlas的源码中进行插件安装过程的分析。 插件的安装分为3种:宿主启动时立
    02-05 安卓开发
  • [译] Android API 指南
    [译] Android API 指南
    众所周知,Android开发者有中文网站了,API 指南一眼看去最左侧的菜单都是中文,然而点进去内容还是很多是英文,并没有全部翻译,我这里整理了API 指南的目录,便于查看,如果之前还没有通读,现在可以好好看一遍。注意,如果标题带有英文,说明官方还没有翻
  • 使用FileProvider解决file:// URI引起的FileUriExposedException
    使用FileProvider解决file:// URI引起的FileUri
    问题以下是一段简单的代码,它调用系统的相机app来拍摄照片:void takePhoto(String cameraPhotoPath) {File cameraPhoto = new File(cameraPhotoPath);Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);takePhotoIntent.putExtra(Medi
    02-05 安卓开发
点击排行