Convert Figma logo to code with AI

Devlight logoNavigationTabBar

Navigation tab bar with colorful interactions.

4,948
857
4,948
65

Top Related Projects

😍 A beautiful, fluid, and extensible dialogs API for Kotlin & Android.

The flexible, easy to use, all in one drawer library for your Android project. Now brand new with material 2 design.

Android Floating Action Button based on Material Design specification

Our Guillotine Menu Transitioning Animation implemented in Swift reminds a bit of a notorious killing machine.

Quick Overview

The Devlight/NavigationTabBar repository provides a customizable and interactive navigation tab bar for Android applications. It offers a visually appealing and user-friendly way to navigate between different sections of an app.

Pros

  • Highly Customizable: The library allows for extensive customization of the tab bar's appearance, including colors, icons, and animations.
  • Smooth Animations: The tab bar transitions between tabs with smooth and fluid animations, enhancing the overall user experience.
  • Responsive Design: The library is designed to work well on a variety of screen sizes and device orientations.
  • Active Development: The project is actively maintained, with regular updates and bug fixes.

Cons

  • Dependency on External Libraries: The library requires the use of additional dependencies, which may increase the overall project size.
  • Limited Documentation: The documentation for the library could be more comprehensive, making it challenging for new users to get started.
  • Potential Performance Issues: Depending on the complexity of the app and the number of tabs, the tab bar may have a noticeable impact on the app's performance.
  • Compatibility Concerns: The library may not be compatible with all versions of Android, which could limit its usability in certain projects.

Code Examples

Initializing the NavigationTabBar

val navigationTabBar = NavigationTabBar(this)
navigationTabBar.addTab(
    NavigationTabBarItem(
        "Home",
        ContextCompat.getDrawable(this, R.drawable.ic_home),
        Color.parseColor("#000000")
    )
)
// Add more tabs as needed

Customizing the NavigationTabBar

navigationTabBar.setModelIndex(0, NavigationTabBarModel(
    ContextCompat.getDrawable(this, R.drawable.ic_home),
    Color.parseColor("#000000"),
    Color.parseColor("#FFFFFF")
))
navigationTabBar.setOnTabBarSelectedIndexListener { index ->
    // Handle tab selection
}

Handling Tab Transitions

navigationTabBar.setOnPageChangeListener(object : ViewPager.OnPageChangeListener {
    override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
        // Handle page scrolling
    }

    override fun onPageSelected(position: Int) {
        // Handle page selection
    }

    override fun onPageScrollStateChanged(state: Int) {
        // Handle page scroll state changes
    }
})

Getting Started

To use the NavigationTabBar in your Android project, follow these steps:

  1. Add the library to your project's build.gradle file:
dependencies {
    implementation 'com.github.Devlight:NavigationTabBar:1.2.5'
}
  1. Initialize the NavigationTabBar in your activity or fragment:
val navigationTabBar = NavigationTabBar(this)
// Add tabs and customize the tab bar as needed
  1. Add the NavigationTabBar to your layout:
<com.gigamole.navigationtabbar.NavigationTabBar
    android:id="@+id/navigation_tab_bar"
    android:layout_width="match_parent"
    android:layout_height="56dp"
    app:ntb_active_color="#000000"
    app:ntb_inactive_color="#7F7F7F"
    app:ntb_title_mode="all"
    app:ntb_titled="true" />
  1. Integrate the tab bar with your app's navigation logic, such as handling tab selection and managing the corresponding content.

Competitor Comparisons

😍 A beautiful, fluid, and extensible dialogs API for Kotlin & Android.

Pros of material-dialogs

  • Provides a wide range of customization options for dialog boxes, including themes, colors, and layouts.
  • Supports various types of dialogs, such as input dialogs, progress dialogs, and custom dialogs.
  • Includes built-in support for Material Design guidelines, ensuring a consistent user experience.

Cons of material-dialogs

  • The library may be more complex and have a steeper learning curve compared to NavigationTabBar.
  • The library may be larger in size and have a higher dependency footprint, which could impact app performance.
  • The library may have a more limited set of pre-built UI components compared to NavigationTabBar.

Code Comparison

NavigationTabBar (Devlight/NavigationTabBar):

val navigationTabBar = NavigationTabBar(this)
navigationTabBar.addTab(
    NavigationTabBar.Model(
        R.drawable.ic_home,
        Color.parseColor("#000000")
    )
)
navigationTabBar.setOnTabSelectedListener { position, title ->
    // Handle tab selection
}

material-dialogs (afollestad/material-dialogs):

MaterialDialog(this)
    .title(text = "Hello, World!")
    .message(text = "This is a material dialog.")
    .positiveButton(text = "OK") { dialog ->
        // Handle positive button click
    }
    .show()

The flexible, easy to use, all in one drawer library for your Android project. Now brand new with material 2 design.

Pros of MaterialDrawer

  • Highly customizable and feature-rich, allowing for a wide range of drawer configurations and styles.
  • Provides a consistent and familiar navigation experience across Android apps.
  • Actively maintained with regular updates and bug fixes.

Cons of MaterialDrawer

  • Larger in size compared to NavigationTabBar, which may impact app size and performance.
  • Steeper learning curve due to the extensive customization options and feature set.
  • May require more boilerplate code to set up and integrate into an app.

Code Comparison

NavigationTabBar:

NavigationTabBar navigationTabBar = new NavigationTabBar.Builder(this)
    .addTab(new NavigationTabBar.Model.Builder(
        getResources().getDrawable(R.drawable.ic_first),
        Color.parseColor("#222222"))
        .title("Home")
        .build())
    .build();

MaterialDrawer:

new DrawerBuilder()
    .withActivity(this)
    .withToolbar(toolbar)
    .addDrawerItems(
        new PrimaryDrawerItem().withIdentifier(1).withName("Home")
    )
    .build();

Android Floating Action Button based on Material Design specification

Pros of Clans/FloatingActionButton

  • Provides a customizable floating action button with various animation options.
  • Supports multiple floating action buttons on the same screen.
  • Includes a built-in menu system for displaying additional actions.

Cons of Clans/FloatingActionButton

  • The library may be overkill for simple use cases where a basic floating action button is sufficient.
  • The documentation and examples could be more comprehensive, making it harder for new users to get started.
  • The library may have a larger footprint compared to a more lightweight implementation.

Code Comparison

Devlight/NavigationTabBar

NavigationTabBar navigationTabBar = new NavigationTabBar.Builder(this)
    .addTab(new NavigationTabBar.Model(
        ContextCompat.getDrawable(this, R.drawable.ic_first),
        Color.parseColor("#000000")))
    .addTab(new NavigationTabBar.Model(
        ContextCompat.getDrawable(this, R.drawable.ic_second),
        Color.parseColor("#d0021b")))
    .build();

Clans/FloatingActionButton

FloatingActionButton fab = new FloatingActionButton.Builder(this)
    .withButtonColor(Color.WHITE)
    .withGravity(Gravity.BOTTOM | Gravity.RIGHT)
    .withMargins(0, 0, 16, 16)
    .create();

Our Guillotine Menu Transitioning Animation implemented in Swift reminds a bit of a notorious killing machine.

Pros of GuillotineMenu

  • Provides a unique and visually appealing menu animation, with a guillotine-like opening and closing effect.
  • Offers a smooth and responsive user experience, with customizable animation duration and easing.
  • Supports both portrait and landscape orientations, making it suitable for a variety of device configurations.

Cons of GuillotineMenu

  • The library may be more complex to integrate and configure compared to NavigationTabBar, as it involves more complex UI elements and animations.
  • The library may have a larger footprint in terms of file size and dependencies, which could impact app performance, especially on older or lower-end devices.

Code Comparison

NavigationTabBar:

val tabBar = NavigationTabBar(this)
tabBar.addTab(TabConfig(R.drawable.ic_home, "Home"))
tabBar.addTab(TabConfig(R.drawable.ic_search, "Search"))
tabBar.addTab(TabConfig(R.drawable.ic_profile, "Profile"))
tabBar.setOnTabSelectListener { position -> /* Handle tab selection */ }

GuillotineMenu:

val guillotineMenu = GuillotineMenu(this)
guillotineMenu.setGuillotineListener { isOpen -> /* Handle menu state change */ }
guillotineMenu.addItem(GuillotineMenuItem("Home", R.drawable.ic_home))
guillotineMenu.addItem(GuillotineMenuItem("Search", R.drawable.ic_search))
guillotineMenu.addItem(GuillotineMenuItem("Profile", R.drawable.ic_profile))

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README


Devlight


NavigationTabBar

Navigation tab bar with colorful interactions.

Android Arsenal       Android       Download       License       Codacy

You can check the sample app here.

Warn

This library is not more supported. 
If you want to add new feature or fix a bug, grab source code and do it. 
If you think your fix or feature would be useful to other developers, 
I can add link of your repository to this README file. 
Thank you for using our libraries.

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.

use navbar using materialize css

navbar using materialize css is really easy and would take just assigning right classes to the html tags and it would create a navigation tab bar using its prewritten css and js files. This can be easily used in html pages using downloaded files or cdn links... https://materializecss.com/navbar.html

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

Facebook     Twitter     LinkedIn

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 info@devlight.io or opensource@devlight.io.
Thanks in advance.

Devlight LLC, 2016
devlight.io