• Stars
    star
    298
  • Rank 137,068 (Top 3 %)
  • Language
    Java
  • License
    MIT License
  • Created over 5 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An android library that allows to use Lottie and create the bottom navigation.

LottieBottomNav

Library which allows to create a bottom navigation view allowing the usage of Lottie views.

Gradle

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}  

dependencies {
    implementation 'com.github.wwdablu:lottiebottomnav:x.y.z'
}

Declare in XML

<com.wwdablu.soumya.lottiebottomnav.LottieBottomNav
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/bottom_nav"
    android:layout_alignParentBottom="true"
    android:background="@android:color/white"
    app:menu_selected_height="48dp"
    app:menu_selected_width="48dp"
    app:menu_unselected_height="40dp"
    app:menu_unselected_width="40dp"
    app:menu_text_show_on_unselected="true"
    />

This would create the LottieBottomNav control. Using it the width and height of the menu items in selected and unselected state of the menu item can be controlled. Also as to whether the text for the menu item will be used for the unselected items can also be controlled using the property menu_text_show_on_unselected.

Creating Menu Items

The LottieBottomNav contains an array of menu items. The process to create a menu item is:

MenuItem homeItem = MenuItemBuilder.create("home.json", MenuItem.Source.Assets, fontItem, "dashboard")
    .pausedProgress(1f)
    .loop(false)
    .build();

This allows us to create a menu with both the selected and unselected states. The other way to create is from an existing menu item object and then modifying any existing property. Note: Only tag property is not copied.

MenuItem settings = MenuItemBuilder.createFrom(homeItem)
    .selectedLottieName("settings.json")
    .unSelectedLottieName("settings.json")
    .tag("settings")
    .build();

In the above approach properties like autoPlay and loop are of the same value from which it is created.

Creating Text Menu Items

These are used to display the text on the menu item. Now, we can also specify custom fonts too.

FontItem fontItem = FontBuilder.create("Dashboard")
    .selectedTextColor(Color.BLACK)
    .unSelectedTextColor(Color.GRAY)
    .selectedTextSize(16) //SP
    .unSelectedTextSize(12) //SP
    .setTypeface(Typeface.createFromAsset(getAssets(), "coffeesugar.ttf"))
    .build();

Update a particular menu item

To update a particular menu item with different properties of the menu item, the following approach is needed.

MenuItem cupidMessage = MenuItemBuilder.createFrom(bottomNav.getMenuItemFor(index))
    .selectedLottieName("message_cupid.json")
    .tag("cupid")
    .build();

bottomNav.updateMenuItemFor(index, cupidMessage);

This would change the lottie used for the menu item in index and update it to use cupid lottie.

Callback

The following callbacks are provided for each of the menu items.

void onMenuSelected(int oldIndex, int newIndex, MenuItem menuItem);
void onAnimationStart(int index, MenuItem menuItem);
void onAnimationEnd(int index, MenuItem menuItem);
void onAnimationCancel(int index, MenuItem menuItem);

It should be noted that if autoPlay is enabled, then it must be noted that onMenuSelected will call onAnimationStart immediately. So it is better to perform quick tasks in these callback and move heavy tasks in separate threads.

Demo

The demo video is present inside the demo folder.

Demo

Lottie Files
The lottie files used have been taken from https://www.lottiefiles.com/. The lotties files have been developed by the respective developers and I have not created them.

Font
The font has been downloaded from https://www.1001fonts.com/coffee-with-sugar-font.html. I have used them for the purpose of demo.

More Repositories

1

SimplyPDF

An android library that allows creation of PDF documents from any android application. It even allows generating PDF by using a JSON structure.
Kotlin
30
star
2

ExtImageView

Android library allowing cropping of images while displaying them to the user. Allows cropping in either defined mode or freeform mode.
Java
12
star
3

wZip

An android library the provides zip and unzip functionality.
Kotlin
10
star
4

Hungry

An application which uses Zomato API to display restaurant information. This is just for the purpose of showing how different libraries can be used to work in conjunction in actual full implementation projects.
Kotlin
10
star
5

ViewAnimator

Android library to perform simple animations with least code
Kotlin
5
star
6

AudioRecorcer

Library that allows to record audio from microphone in Android.
Java
3
star
7

ARGallery

Using Sceneform to render bitmaps from Gallery using ViewRenderable and ShapeRenderable.
Java
3
star
8

Blurred

Library used to blur images and text on TextView for Android
Java
2
star
9

CamPDF

Allows the user to click images and then save them as PDF, Images.
Java
2
star
10

PhoneInputExt

Android custom view which allows the user to display the phone input field containing the flag of the current country with the country code. Allows the user to select from list of countries with the country code.
Kotlin
2
star
11

SceneformAnimate

An application to demonstrate the usage of Sceneform in Android.
Java
1
star
12

QuickCapture

C# application which allows quick screen capture and save them directly to an image file.
C#
1
star
13

GuidedEditText

UI component that can be attached to an EditText view which shows guides(rules) which are needed to be satisfied to have a proper entry.
Kotlin
1
star
14

bitbeauty

Android library which allows bitmap creation and editing them easily
Kotlin
1
star
15

BarQR

Application to scan and fetch barcode and QR code data using zxing library.
Java
1
star