NavigationTabBar


Source link: https://github.com/Devlight/NavigationTabBar



NavigationTabBar

Navigation tab bar with colorful interactions.

                       

You can check the sample app here.

Download

You can download a .aar from GitHub's releases page.

You can use Gradle:

compile 'devlight.io:navigationtabbar:1.2.5'

Or Maven:

<dependency>
  <groupId>devlight.io</groupId>
  <artifactId>navigationtabbar</artifactId>
  <version>1.2.5</version>
  <type>aar</type> </dependency>

Or Ivy:

<dependency org='devlight.io' name='navigationtabbar' rev='1.2.5'>
<artifact name='$AID' ext='pom'></artifact> </dependency>

Android SDK Version

NavigationTabBar requires a minimum SDK version of 11.

Sample

Parameters

For NTB you can set such parameters as:

  • models:
    allows you to set NTB models, where you set icon and color. Can be set up only via code.

  • behavior:
    allows you to set bottom translation behavior.

  • view pager:
    allows you to connect NTB with ViewPager. If you want your can also set OnPageChangeListener.

  • background color:
    allows you to set background to NTB which automatically set with offset relative to badge gravity and corners radius.

  • model selected icon:
    allows you to set selected icon when current model is active.

  • model title:
    allows you to enable title in you model.

  • model badge:
    allows you to enable badge in you model.

  • use custom typeface on badge:
    allows you to handle set of custom typeface in your badge.

  • title mode:
    allows you to handle mode of the model title show. Can show all or only active.

  • title size:
    allows you to set titles size.

  • scale mode:
    allows you to handle mode of the model icon and title scale.

  • tint mode:
    allows you to enable or disable icon tinting.

  • badge size:
    allows you to set badges size.

  • badge position:
    allows you to set the badge position in you model. Can be: left(25%), center(50%) and right(75%).

  • badge gravity:
    allows you to set the badge gravity in NTB. Can be top or bottom.

  • badge colors:
    allows you to set the badge bg and title colors.

  • typeface:
    allows you to set custom typeface to your title.

  • corners radius:
    allows you to set corners radius of pointer.

  • icon size fraction:
    allows you to set icon size fraction relative to smaller model side.

  • animation duration:
    allows you to set animation duration.

  • inactive color:
    allows you to set inactive icon color.

  • active color:
    allows you to set active icon color.

  • tab bar listener:
    allows you to set listener which triggering on start or on end when you set model index.

  • preview colors:
    allows you to set preview colors, which generate count of models equals to count of colors.

Tips

Creation of models occurs through Builder pattern.
ModelBuilder requires two fields: icon and color. Title, badge title and selected icon is optional.

You can set selected icon. Resize and scale of selected icon equals to original icon.
Orientation automatically detected according to View size.

By default badge bg color is the active model color and badge title color is the model bg color. To reset colors just set AUTO_COLOR value to badge bg and title color.
By default badge sizes and title sizes is auto fit. To reset calculation just set AUTO_SIZE value to badge size and title size.
By default icon size fraction is 0.5F (half of smaller side of NTB model). To reset scale fraction of icon to automatic just put in method AUTO_SCALE value.

If your set ViewPager and enable swipe you can action down on active pointer and do like drag.

Init

Check out in code init:

final NavigationTabBar navigationTabBar = (NavigationTabBar) findViewById(R.id.ntb);
 final ArrayList<NavigationTabBar.Model> models = new ArrayList<>();
 models.add(

new NavigationTabBar.Model.Builder(

  getResources().getDrawable(R.drawable.ic_first),

  Color.parseColor(colors[0])

).title("Heart")

  .badgeTitle("NTB")

  .build() );
 models.add(

new NavigationTabBar.Model.Builder(

  getResources().getDrawable(R.drawable.ic_second),

  Color.parseColor(colors[1])

).title("Cup")

  .badgeTitle("with")

  .build() );
 models.add(

new NavigationTabBar.Model.Builder(

  getResources().getDrawable(R.drawable.ic_third),

  Color.parseColor(colors[2])

).title("Diploma")

  .badgeTitle("state")

  .build() );
 models.add(

new NavigationTabBar.Model.Builder(

  getResources().getDrawable(R.drawable.ic_fourth),

  Color.parseColor(colors[3])

).title("Flag")

  .badgeTitle("icon")

  .build() );
 models.add(

new NavigationTabBar.Model.Builder(

  getResources().getDrawable(R.drawable.ic_fifth),

  Color.parseColor(colors[4])

).title("Medal")

  .badgeTitle("777")

  .build() );
 navigationTabBar.setModels(models);
 navigationTabBar.setViewPager(viewPager, 2);
  navigationTabBar.setTitleMode(NavigationTabBar.TitleMode.ACTIVE);
 navigationTabBar.setBadgeGravity(NavigationTabBar.BadgeGravity.BOTTOM);
 navigationTabBar.setBadgePosition(NavigationTabBar.BadgePosition.CENTER);
 navigationTabBar.setTypeface("fonts/custom_font.ttf");
 navigationTabBar.setIsBadged(true);
 navigationTabBar.setIsTitled(true);
 navigationTabBar.setIsTinted(true);
 navigationTabBar.setIsBadgeUseTypeface(true);
 navigationTabBar.setBadgeBgColor(Color.RED);
 navigationTabBar.setBadgeTitleColor(Color.WHITE);
 navigationTabBar.setIsSwiped(true);
 navigationTabBar.setBgColor(Color.BLACK);
 navigationTabBar.setBadgeSize(10);
 navigationTabBar.setTitleSize(10);
 navigationTabBar.setIconSizeFraction(0.5);

If your models is in badge mode you can set title, hide, show, toggle and update badge title like this:

model.setTitle("Here some title to model");
 model.hideBadge();
 model.showBadge();
 model.toggleBadge();
 model.updateBadgeTitle("Here some title like NEW or some integer value");

To enable behavior translation inside CoordinatorLayout when at bottom of screen:

navigationTabBar.setBehaviorEnabled(true);

To deselect active index and reset pointer:

navigationTabBar.deselect();

Other methods check out in sample.

And XML init:

<devlight.io.library.ntb.NavigationTabBar
 android:id="@+id/ntb"
 android:layout_width="match_parent"
 android:layout_height="50dp"
 app:ntb_animation_duration="400"
 app:ntb_preview_colors="@array/colors"
 app:ntb_corners_radius="10dp"
 app:ntb_active_color="#fff"
 app:ntb_inactive_color="#000"
 app:ntb_badged="true"
 app:ntb_titled="true"
 app:ntb_scaled="true"
 app:ntb_tinted="true"
 app:ntb_title_mode="all"
 app:ntb_badge_position="right"
 app:ntb_badge_gravity="top"
 app:ntb_badge_bg_color="#ffff0000"
 app:ntb_badge_title_color="#ffffffff"
 app:ntb_typeface="fonts/custom_typeface.ttf"
 app:ntb_badge_use_typeface="true"
 app:ntb_swiped="true"
 app:ntb_bg_color="#000"
 app:ntb_icon_size_fraction="0.5"
 app:ntb_badge_size="10sp"
 app:ntb_title_size="10sp"/>

XML??????:

<devlight.io.library.ntb.NavigationTabBar ?????
  ??:
  app:ntb_bg_color="#000"

 ntb?????

 ????
  app:ntb_active_color="#000"

ntb??????+????

????
  app:ntb_inactive_color="#0f0"

 ntb???????+????
 ????
  app:ntb_corners_radius="10dp"

 ntb??????????

 ????
  app:ntb_animation_duration="1000"
ntb????????

  ??:ms
  ????:
  app:ntb_icon_size_fraction="1"

?????????

???:0.5
  ????:
  app:ntb_titled="true"

????????????

 ???false
  app:ntb_title_mode="active"

????????????

 active:?????? all:????  PS:app:ntb_titled???? true ????
  app:ntb_title_size="10sp"

  ??????????????
 ????
  ????:
  app:ntb_badged="false"

  ??????

???false
  app:ntb_badge_gravity="top"

???????

 top|bottom
  app:ntb_badge_position="right"

???????

 left(25%), center(50%) and right(75%)
  app:ntb_badge_bg_color="#ffff0000"  ???????

 ????
  app:ntb_badge_title_color="#000000" ?????????

 ???? PS:????????????????
  app:ntb_badge_size="12sp"

  ?????????

 ????
  ????:
  app:ntb_badge_use_typeface="false"  ?????????

 ???false
  app:ntb_typeface="fonts/by3500.ttf" ??ntb??????

???????????? asset/fonts ????
  ??:
  app:ntb_preview_colors="@array/colors"
  app:ntb_scaled="true"
  app:ntb_tinted="true"
  app:ntb_swiped="true"/>

Getting Help

To report a specific problem or feature request, open a new issue on Github.

Xamarin

Thanks to Martijn van Dijk for developing Xamarin bindings library for NavigationTabBar.
Plugin is available on Nuget.

Credits

Sincere thanks, to portal FAnDroid.info (StartAndroid) who released the review of this library in detail. If you understand the Russian language, then feel free to see the video or read the text version of its great post.

Inspired by:

Sergey Valiukh

Thanks to Valery Nuzhniy for NTB badge design.

Author

Created by Basil Miller - @gigamole

Company

           

Here you can see open source work developed by Devlight LLC.
This and another works is an exclusive property of Devlight LLC.

If you want to use this library in applications which will be available on Google Play, please report us about it or author of the library.

Whether you're searching for a new partner or trusted team for creating your new great product we are always ready to start work with you.

You can contact us via [email protected] or [email protected].
Thanks in advance.

Devlight LLC, 2016
devlight.io

Resources

BetterTextInputLayout is Android support library's TextInputLayout subclass providing following extensions: adds methods to manipulate password visibility from code as showPassword, hidePassword and togglePassword also comes with passwordToggleEnabled enabled by default.

Custom ProgressView to show battery progress.

A library for speedy implementation menu or some actions with BottomSheet.

Piri is a lightweight annotation processing library that generates static factory methods which creates new intents for activities in Android.

It is a debug library to easily measure communication traffic of network of Activity.

A simple customizable Music Indicator Animation library. You can animate bars when the audio is played.

Features

  • Animate Indicator Bars
  • Set duration
  • Set color

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes