Git Product home page Git Product logo

gauravk95 / bubble-navigation Goto Github PK

View Code? Open in Web Editor NEW
1.7K 33.0 209.0 9.26 MB

๐ŸŽ‰ [Android Library] A light-weight library to easily make beautiful Navigation Bar with ton of ๐ŸŽจ customization option.

License: Apache License 2.0

Kotlin 18.06% Java 81.94%
android android-ui android-ui-insipired android-library library navigation bottomnavigationview bottom-navigation bottomnavigation bottomnavigationbar navigationbar navigationview navigation-view navbar widget material-design

bubble-navigation's Introduction

Bubble Navigation

API Download Build Status Android Arsenal Android Weekly AwesomeAndroid

๐ŸŽ‰ 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
    • BubbleNavigationConstraintView: supports 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.gradle file
repositories {
    google()
    jcenter()
 }
  • To use it, add the following to build.gradle for 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/top_navigation_constraint"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        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/c_item_rest"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:bt_active="true"
            app:bt_colorActive="@color/search_active"
            app:bt_colorInactive="@color/search_inactive"
            app:bt_icon="@drawable/ic_restaurant"
            app:bt_shape="@drawable/transition_background_drawable_restaurant"
            app:bt_title="@string/restaurant"
            app:bt_padding="@dimen/internal_padding"
            app:bt_titlePadding="@dimen/title_padding" />

         <!-- 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/bottom_navigation_view_linear"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:elevation="8dp"
        android:orientation="horizontal"
        android:padding="12dp">

        <com.gauravk.bubblenavigation.BubbleToggleView
            android:id="@+id/l_item_home"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:bt_active="true"
            app:bt_colorActive="@color/home_active"
            app:bt_colorInactive="@color/home_inactive"
            app:bt_icon="@drawable/ic_home"
            app:bt_shape="@drawable/transition_background_drawable_home"
            app:bt_title="@string/home"
            app:bt_padding="@dimen/internal_padding"
            app:bt_titlePadding="@dimen/title_padding" />
  
    <!-- Add more child items here - max upto 5 -->
    
    </com.gauravk.bubblenavigation.BubbleNavigationLinearView>

Using BubbleToggleView

BubbleToggleView is designed to work as a child component for the BubbleNavigationLinearView and BubbleNavigationConstraintView. This view can be used independently for:

  • Custom implementation of NavigationBar
  • Creation of new UI components
  • ToggleView
attr Description
bt_active Sets to Active State
bt_colorActive When in Active State, uses this color for the Icon and Title
bt_colorInctive When in Inactive State, uses this color for the Icon and Title
bt_icon Sets the Icon Drawable
bt_iconWidth Updates the Icon Width
bt_iconHeigth Updates the Icon Height
bt_title Sets the Title Text
bt_titleSize Updates the Tilte Text Size in sp
bt_shape Sets the Background Drawable. Use TransitionDrawable to get fade in-out effect when toggling
bt_showShapeAlways If true and using Normal drawable, background shape remains visible always
bt_shapeColor Changes the tint color of the shape. N/A when using TransitionDrawable or showShapeAlways is true.
bt_duration Sets time duration for toggle animation to complete in ms
bt_padding Sets the internal padding in dp
bt_titlePadding Sets the title padding in dp
bt_badgeText Sets the text for the badge
bt_badgeTextSize Sets the font size of the badge text
bt_badgeTextColor Sets the text color of the badge
bt_badgeBackgroundColor Sets the background color of the badge

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 Java

  bubbleNavigation.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 [email protected]

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.

bubble-navigation's People

Contributors

gauravk95 avatar monomagentaeggroll avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bubble-navigation's Issues

Issue with text being cutoff on buttons

Even with only 3 buttons, the third button's text is cut off.

Text: "Dashboard"
Text visible: "Dashboar"

Would it be possible to allow configuration of padding around the textview?

Not work in API 32

Could not find com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3. in SDK 32

Text cut

When apply custom font then text cut in bubble view.

[RFC] Closing pull requests while a new build is starting causes failures

Build failures often indicate a fault with the software being built such as compilation or test failures. However, there is a subset of build failures (called environmental or non-verification failures) that are not expected within a standard application development lifecycle, such as build configuration failures, dependency resolution failures, infrastructure failures, and so on.

Problem: One type of environmental failure is due to due to git references being no longer available at the time a build job starts. For example, pull requests are merged shortly before the start of the scheduled build, causing a build failure due to an unfound (because merged) branch. In your project, we detected 1 failure of this type over the May-June timespan. For instance, we found that Build #26 did not pass due to the above issue.

Solution: It is generally recommended to wait for the build results before merging a pull request. If you wish to skip builds you may also use the SKIP CI tag in your commit message. Additionally, it is also possible to skip builds containing non-code changes as shown in this example and below:

+ before_install:
+  - |
+      if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(.md)|(.png)|(.pdf)|(.html)|^(LICENSE)|^(docs)'
+      then
+        echo "Only doc files were updated, not running the CI."
+        exit
+      fi

Disclaimer: I developed a tool that repairs environmental build failures and I am now evaluating its usefulness for open-source projects.

Please up/downvote the issue to indicate whether you agree/disagree with the report and the proposed fix.

Set custom font

Thanks for this great library.
How can i set custom font for texts?

Class problem/Error

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    
    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:animateLayoutChanges="true"
        android:fitsSystemWindows="true"
        android:layout_above="@+id/bottomNavigationView">

        <com.google.android.material.appbar.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/AppTheme.AppBarOverlay">

            <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:popupTheme="@style/AppTheme.PopupOverlay"/>

        </com.google.android.material.appbar.AppBarLayout>

        <FrameLayout
            android:id="@+id/fragment_container"
            android:layout_width="match_parent"   
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

    </androidx.coordinatorlayout.widget.CoordinatorLayout>

	<com.gauravk.bubblenavigation.BubbleNavigationConstraintView
        android:id="@+id/top_navigation_constraint"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="380dp"
        android:background="#FFFFFDFB"
        android:elevation="4dp"
        android:padding="12dp"
        app:bnc_mode="spread">

        <com.gauravk.bubblenavigation.BubbleToggleView
            android:id="@+id/c_item_rest"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:bt_active="true"
            app:bt_colorActive="#FFFDE9DF"
            app:bt_colorInactive="#FFF7F7F7"
            app:bt_icon="@drawable/iconoir_home"
            app:bt_shape="@drawable/iconoir_home"
            app:bt_title=""
            app:bt_padding="8dp"
            app:bt_titlePadding="0dp" />


    </com.gauravk.bubblenavigation.BubbleNavigationConstraintView>
</RelativeLayout>

Error :

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app/com.example.app.activities.MainActivity}: android.view.InflateException: Binary XML file line #37: Binary XML file line #37: Error inflating class com.gauravk.bubblenavigation.BubbleNavigationConstraintView
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2572)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
	at android.app.ActivityThread.-wrap11(ActivityThread.java)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
	at android.os.Handler.dispatchMessage(Handler.java:111)
	at android.os.Looper.loop(Looper.java:207)
	at android.app.ActivityThread.main(ActivityThread.java:5728)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
Caused by: android.view.InflateException: Binary XML file line #37: Binary XML file line #37: Error inflating class com.gauravk.bubblenavigation.BubbleNavigationConstraintView
	at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
	at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
	at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
	at com.example.app.activities.MainActivity.onCreate(MainActivity.java:23)
	at android.app.Activity.performCreate(Activity.java:6301)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
	... 9 more
Caused by: android.view.InflateException: Binary XML file line #37: Error inflating class com.gauravk.bubblenavigation.BubbleNavigationConstraintView
	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
	... 17 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.gauravk.bubblenavigation.BubbleNavigationConstraintView" on path: DexPathList[[zip file "/data/app/com.example.app-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.app-1/lib/arm, /vendor/lib, /system/lib]]
	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
	at android.view.LayoutInflater.createView(LayoutInflater.java:583)
	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
	... 21 more
	Suppressed: java.lang.NoClassDefFoundError: com.gauravk.bubblenavigation.BubbleNavigationConstraintView
		at dalvik.system.DexFile.defineClassNative(Native Method)
		at dalvik.system.DexFile.defineClass(DexFile.java:226)
		at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
		at dalvik.system.DexPathList.findClass(DexPathList.java:338)
		at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
		... 25 more
	Suppressed: java.lang.ClassNotFoundException: com.gauravk.bubblenavigation.BubbleNavigationConstraintView
		at java.lang.Class.classForName(Native Method)
		at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
		at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
		at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
		... 24 more
	Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

Use multiple drawable for items .

I think use only a single drawable is enough for menu item . and (tint )change the color according the .

app:bt_shape="@drawable/transition_background_drawable_home"

android component navigation not working

when I want to use custom navigation (BubbleNavigationLinearView) in android component navigation I can't use them because I can't find any code for replacing with below code and "setupWithNavController" feature is not enabled for this custom navigation, just enable for "bottom navigation".

BubbleNavigationLinearView navigation;
NavController navController;

navigation = findViewById(R.id.navigation);
navController = Navigation.findNavController(this, R.id.fragment);

navigation.setupWithNavController(navController); <---------------------- for this one
so if you know my problem answers please help me.

bt_icon not changing on state changed.

I am trying to change Icon of selected tab based on selection but not able to change it.

I am using Selector to switch the icons.
Icons do not support vector images (SVGs) below API level 23.

Use in activitymain.xml

 <com.gauravk.bubblenavigation.BubbleToggleView
                android:id="@+id/tab_home"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:bt_active="true"
                app:bt_badgeTextColor="@color/darkPurple"
                app:bt_colorActive="@color/darkPurple"
                app:bt_colorInactive="@color/light_black"
                app:bt_icon="@drawable/home_tab_selector"
                app:bt_padding="10dp"
                app:bt_shape="@drawable/background_stroke"
                app:bt_title="@string/home_tab"
                app:bt_titleSize="12dp"/>

Selector: home_tab_selector.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/icon1" android:state_active="true" />
    <item android:drawable="@drawable/icon2" android:state_active="false" />

</selector>

Moreover, elevation is not working as it should. Also not getting the Shadow effect.

Is there any other way to do so? Please let me know.

Thanks.

Cannot use databinding with bt_title

I want to use databinding with bt_title.
How can i do it?

<com.gauravk.bubblenavigation.BubbleToggleView
                android:id="@+id/l_item_home"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:bt_active="true"
                app:bt_colorActive="@color/red_active"
                app:bt_colorInactive="@color/red_inactive"
                app:bt_icon="@drawable/ic_home"
                app:bt_shape="@drawable/transition_background_drawable_home"
                app:bt_title="@{String.valueOf(viewmodel.currentNumber)}" />

Add Real fragments

How to Add fragments instead of colors

your code
ArrayList fragList = new ArrayList<>();
fragList.add(ScreenSlidePageFragment.newInstance(getString(R.string.home), R.color.red_inactive));
fragList.add(ScreenSlidePageFragment.newInstance(getString(R.string.search), R.color.blue_inactive));

i want

ArrayList fragList = new ArrayList<>();
fragList.add(new firstFragement());
4 more.

please look in to it

not showing xml code

when i add the dependancy in the gradle the gradle sysnc perfectly but when i past the xml code of bubble nav bar it does not show up

Title text Color limitation

I want to the different color of title from Icon but I can't.
the app:bt_colorActive set color for both Icon and Title.
So, how to do it?

Invalid drawable tag vector on pre Lollipop

Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_artist.xml from drawable resource ID #0x7f0700b8
        at android.content.res.Resources.loadDrawable(Resources.java:2842)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
        at com.gauravk.bubblenavigation.BubbleToggleView.init(BubbleToggleView.java:118)
        at com.gauravk.bubblenavigation.BubbleToggleView.<init>(BubbleToggleView.java:71)
     Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #1: invalid drawable tag vector
        at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:917)
        at android.graphics.drawable.Drawable.createFromXml(Drawable.java:858)
        at android.content.res.Resources.loadDrawable(Resources.java:2839)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:602)ย 
        at com.gauravk.bubblenavigation.BubbleToggleView.init(BubbleToggleView.java:118)ย 
        at com.gauravk.bubblenavigation.BubbleToggleView.<init>(BubbleToggleView.java:71)ย 

maybe VectorDrawableCompat.create() shoud fix it?

rounded corner

excuse me
i want to know how i could rounded top right & top left corner of this bottom navigation

Nullpointer when trying to inital start with other then first item

I'm trying to start wit another then the first item in Bubble-Navigation, but when i try to setCurrentActiveItem in onViewCreated I get a NullPointer (see below). How can I achieve to initial select another than the first item?

The exception:

java.lang.NullPointerException: Attempt to invoke virtual method 'int java.util.ArrayList.size()' on a null object reference
        at com.gauravk.bubblenavigation.BubbleNavigationConstraintView.setCurrentActiveItem(BubbleNavigationConstraintView.java:294)

This is my code, nothing very special here, just trying to keep viewpager and navigation in sync and have the possibility to start with last item:

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        adapter = Adapter(childFragmentManager)
        cv_navigation.setNavigationChangeListener { navView, position ->
            viewPager.setCurrentItem(position,true)
        }
        viewPager.adapter = adapter
        viewPager.addOnPageChangeListener(object: ViewPager.OnPageChangeListener {
            override fun onPageScrollStateChanged(state: Int) {
            }

            override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
            }

            override fun onPageSelected(position: Int) {
                    cv_navigation.setCurrentActiveItem(position);
            }
        })
        if (arguments != null && savedInstanceState == null && arguments!!.getBoolean(USE_LAST)) {
            viewPager.currentItem = adapter!!.count - 1;
        }
    }

how to make item not selectable ?

I want to show fragments and activity both. Suppose i have 5 items from which i have to open activity for 3rd item. When i switch to activity and come back 3rd item gets selected.How to make it select the last user visible item?

new intent in bottom navigation

how can i use bottom nevigation to change activity in bottom click
becouse there is not any option to change state

BubbleNavigationLinearView bubbleNavigation = (BubbleNavigationLinearView)findViewById(R.id.bottom_navigation_view_linear);

bubbleNavigation.setNavigationChangeListener(new BubbleNavigationChangeListener() {
    @Override
    public void onNavigationChanged(View view, int position) {
        switch (position.getItemId())
    }
});

getItemId showing error so how can i choose id to change activity in on click

@gauravk95
Owner

OnResume How to State change in Java Code

Hello
Good Evening , Please mention me when anther activity on success then button cuurent state position are not showing by defult home state are show . please help mee

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.