๐ [Android Library] A light-weight library to easily make beautiful Navigation Bar with ton of ๐จ customization option.
Bubble Navigation
๐ A light-weight library to easily make beautiful Navigation Bars with a ton of ๐จ customization options.
Demos
| FloatingTopBarActivity | TopBarActivity | | ------------- |:-------------:| |
|
|
| BottomBarActivity | EqualBottomBarActivity | | ------------- |:-------------:| |
|
|
Features:
- Support for API Level 16+
- Highly customizable
- Light weight and easy-to-use
- Supports TransitionDrawable for cool state changes
- 2 types of NavigationView for different use cases
spread, inside and packed mode
- BubbleNavigationLinearView: allows equal distribution using weight or packed mode
- Bonus BubbleToggleView to create new UI components, other than navigation
- Add Badges
Usage
Check out the Sample app, to see how its implemented.
Gradle
- This library is available on JCenter. First, Make sure to add the following in your project level
build.gradlefile
repositories {
google()
jcenter()
}
- To use it, add the following to
build.gradlefor the module
dependencies {
implementation 'com.gauravk.bubblenavigation:bubblenavigation:1.0.7'
}
XML
NOTE: MINMUM 2 child items are required
<com.gauravk.bubblenavigation.BubbleNavigationConstraintView
android:id="@+id/topnavigationconstraint"
android:layoutwidth="matchparent"
android:layoutheight="wrapcontent"
android:layout_marginBottom="380dp"
android:background="@color/white"
android:elevation="4dp"
android:padding="12dp"
app:bnc_mode="spread">
<com.gauravk.bubblenavigation.BubbleToggleView android:id="@+id/citemrest" android:layoutwidth="wrapcontent" android:layoutheight="wrapcontent" app:bt_active="true" app:btcolorActive="@color/searchactive" app:btcolorInactive="@color/searchinactive" app:bticon="@drawable/icrestaurant" app:btshape="@drawable/transitionbackgrounddrawablerestaurant" app:bt_title="@string/restaurant" app:btpadding="@dimen/internalpadding" app:bttitlePadding="@dimen/titlepadding" />
<!-- Add more child items here - max upto 5 --> </com.gauravk.bubblenavigation.BubbleNavigationConstraintView>
| attr | Description | | ------------ | ----------------------------------------------------- | | bnc_mode | Changes the display mode the child elements | | | - spread : equally distributes the child elements | | | - packed : elements are packed with center gravity| | | - inside : inside elements are equally distributed|
OR
<com.gauravk.bubblenavigation.BubbleNavigationLinearView
android:id="@+id/bottomnavigationview_linear"
android:layoutwidth="matchparent"
android:layoutheight="wrapcontent"
android:background="@color/white"
android:elevation="8dp"
android:orientation="horizontal"
android:padding="12dp">
<com.gauravk.bubblenavigation.BubbleToggleView android:id="@+id/litemhome" android:layoutwidth="wrapcontent" android:layoutheight="wrapcontent" app:bt_active="true" app:btcolorActive="@color/homeactive" app:btcolorInactive="@color/homeinactive" app:bticon="@drawable/ichome" app:btshape="@drawable/transitionbackgrounddrawablehome" app:bt_title="@string/home" app:btpadding="@dimen/internalpadding" app:bttitlePadding="@dimen/titlepadding" /> <!-- Add more child items here - max upto 5 --> </com.gauravk.bubblenavigation.BubbleNavigationLinearView>
Using BubbleToggleView
BubbleToggleView is designed to work as a child component for theBubbleNavigationLinearView and BubbleNavigationConstraintView. This view can be used independently for: - Custom implementation of NavigationBar
- Creation of new UI components
- ToggleView
Note: Normal drawables may retain the shape of each Navigation item. Setting the same drawable for each item with different bt_shapeColor properties produces a similar effect while lowering memory usage and improving performance.
Activity/Fragment
In JavabubbleNavigation.setNavigationChangeListener(new BubbleNavigationChangeListener() { @Override public void onNavigationChanged(View view, int position) { //navigation changed, do something } }); Or in Kotlin navigation_view.setNavigationChangeListener { view , position -> //navigation changed, do something here } | Method | Description | | ------------- | ------------- | | void setCurrentActiveItem(int position) | Changes the current active state for the navigation view | | void setTypeface(Typeface typeface) | Updates the typeface of the text | | void setNavigationChangeListener(BubbleNavigationChangeListener listener) | Sets the navigation change listener| | int getCurrentActiveItemPosition() | Returns the current active position | | void setBadgeValue(int position, String value) | Updates the corresponding badge text value |
Contribute
Users are welcome to suggest ideas or feature requests, or report bugs and issues here
I am always open to new suggestions and good contributions.
Contact
Feel free to reach out to me at gauravkcs50@gmail.com
License:
Copyright 2019 Gaurav Kumar
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.