Giter VIP home page Giter VIP logo

animatedbottombar's Introduction

AnimatedBottomBar





A customizable and easy to use BottomBar navigation view with sleek animations, with support for ViewPager, ViewPager2, NavController, and badges.

           By Joery Droppers

Screenshots

Playground app

Download the playground app from Google Play, with this app you can try out all features and even generate XML with your selected configuration.

Contents

Getting started

This library is available on Maven Central, install it by adding the following dependency to your build.gradle:

implementation 'nl.joery.animatedbottombar:library:1.1.0'

Versions 1.0.x can only be used with jCenter, versions 1.1.x and up can be used with Maven Central.

Define AnimatedBottomBar in your XML layout with custom attributes.

<nl.joery.animatedbottombar.AnimatedBottomBar
    android:id="@+id/bottom_bar"
    android:background="#FFF"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:abb_selectedTabType="text"
    app:abb_indicatorAppearance="round"
    app:abb_indicatorMargin="16dp"
    app:abb_indicatorHeight="4dp"
    app:abb_tabs="@menu/tabs"
    app:abb_selectedIndex="1" />

Create a file named tabs.xml in the res/menu/ resources folder:

<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/tab_home"
        android:icon="@drawable/home"
        android:title="@string/home" />
    <item
        android:id="@+id/tab_alarm"
        android:icon="@drawable/alarm"
        android:title="@string/alarm" />
    <item
        android:id="@+id/tab_bread"
        android:icon="@drawable/bread"
        android:title="@string/bread" />
    <item
        android:id="@+id/tab_cart"
        android:icon="@drawable/cart"
        android:title="@string/cart" />
</menu>

Get notified when the selected tab changes by setting callbacks:

bottom_bar.onTabSelected = {
    Log.d("bottom_bar", "Selected tab: " + it.title)
}
bottom_bar.onTabReselected = {
    Log.d("bottom_bar", "Reselected tab: " + it.title)
}

Or set a listener if you need more detailed information:

bottom_bar.setOnTabSelectListener(object : AnimatedBottomBar.OnTabSelectListener {
    override fun onTabSelected(
        lastIndex: Int,
        lastTab: AnimatedBottomBar.Tab?,
        newIndex: Int,
        newTab: AnimatedBottomBar.Tab
    ) {
        Log.d("bottom_bar", "Selected index: $newIndex, title: ${newTab.title}")
    }

    // An optional method that will be fired whenever an already selected tab has been selected again.
    override fun onTabReselected(index: Int, tab: AnimatedBottomBar.Tab) {
        Log.d("bottom_bar", "Reselected index: $index, title: ${tab.title}")
    }
})

Managing tabs

Short overview on how to manage tabs using code.

Creating new tabs

// Creating a tab by passing values
val bottomBarTab1 = AnimatedBottomBar.createTab(drawable, "Tab 1")

// Creating a tab by passing resources
val bottomBarTab2 = AnimatedBottomBar.createTab(R.drawable.ic_home, R.string.tab_2, R.id.tab_home)

Adding new tabs

// Adding a tab at the end
AnimatedBottomBar.addTab(bottomBarTab1)

// Add a tab at a specific position
AnimatedBottomBar.addTabAt(1, bottomBarTab2)

Removing tabs

// Removing a tab by object reference
val tabToRemove = AnimatedBottomBar.tabs[1]
AnimatedBottomBar.removeTab(tabToRemove)

// Removing a tab at a specific position
AnimatedBottomBar.removeTabAt(tabPosition)

// Removing a tab by the given ID resource
AnimatedBottomBar.removeTabById(R.id.tab_home)

Selecting tabs

// Selecting a tab by object reference
val tabToSelect = AnimatedBottomBar.tabs[1]
AnimatedBottomBar.selectTab(tabToSelect)

// Selecting a tab at a specific position
AnimatedBottomBar.selectTabAt(1)

// Selecting a tab by the given ID resource
AnimatedBottomBar.selectTabById(R.id.tab_home)

Enabling / disabling tabs

// Disabling a tab by object reference
val tabToDisable = AnimatedBottomBar.tabs[1]
AnimatedBottomBar.setTabEnabled(tabToDisable, false) // Use true for re-enabling the tab

// Disabling a tab at a specific position
AnimatedBottomBar.setTabEnabledAt(1, false)

// Disabling a tab by the given ID resource
AnimatedBottomBar.setTabEnabledById(R.id.tab_home, false)

Intercepting tabs

This could be useful for example restricting access to a premium area. You can use a callback or a more detailed listener:

bottom_bar.onTabIntercepted = {
    if (newTab.id == R.id.tab_pro_feature && !hasProVersion) {
        // e.g. show a dialog
        false
    }
    true
}

Detailed listener:

bottom_bar.setOnTabInterceptListener(object : AnimatedBottomBar.OnTabInterceptListener {
    override fun onTabIntercepted(
        lastIndex: Int,
        lastTab: AnimatedBottomBar.Tab?,
        newIndex: Int,
        newTab: AnimatedBottomBar.Tab
    ): Boolean {
        if (newTab.id == R.id.tab_pro_feature && !hasProVersion) {
            // e.g. show a dialog
            return false
        }
        return true
    }
})

Tab badges

Instructions on how to set badges for tabs, a AnimatedBottomBar.Badge object should be supplied to the BottomBar, note that it is also possible to add badges without text.

Adding badges

// Adding a badge by tab reference
val tabToAddBadgeAt = AnimatedBottomBar.tabs[1]
AnimatedBottomBar.setBadgeAtTab(tabToAddBadgeAt, AnimatedBottomBar.Badge("99"))

// Adding a badge at a specific position
AnimatedBottomBar.setBadgeAtTabIndex(1, AnimatedBottomBar.Badge("99"))

// Adding a badge at the given ID resource
AnimatedBottomBar.setBadgeAtTabId(R.id.tab_home, AnimatedBottomBar.Badge("99"))

Removing badges

// Removing a badge by tab reference
val tabToRemoveBadgeFrom = AnimatedBottomBar.tabs[1]
AnimatedBottomBar.clearBadgeAtTab(tabToRemoveBadgeFrom)

// Removing a badge at a specific position
AnimatedBottomBar.clearBadgeAtTabIndex(1, AnimatedBottomBar.Badge("99"))

// removing a badge at the given ID resource
AnimatedBottomBar.clearBadgeAtTabId(R.id.tab_home, AnimatedBottomBar.Badge("99"))

Styling individual badges

Additionally there is also the possibility to individually style badges.

AnimatedBottomBar.Badge(
    text = "99",
    backgroundColor = Color.RED,
    textColor = Color.GREEN,
    textSize =  12.spPx // in pixels
)

Usage with ViewPager

It is easy to use the BottomBar with a ViewPager or ViewPager2, you can simply use the setupWithViewPager() method. Please note that the number of tabs and ViewPager pages need to be identical in order for it to function properly.

Usage

// For ViewPager use:
bottom_bar.setupWithViewPager(yourViewPager)

// For ViewPager2 use:
bottom_bar.setupWithViewPager2(yourViewPager2)

Configuration

An overview of all configuration options. All options can also be accessed and set programmatically, by their equivalent name.

Tabs

Attribute Description Default
abb_tabs Tabs can be defined in a menu file (Menu resource), in the res/menu/ resource folder.

The icon and title attribute are required. By default all tabs are enabled, set android:enabled to false to disable a tab.
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/tab_example"
        android:icon="@drawable/ic_example"
        android:title="@string/tab_example"
        android:enabled="true|false" />
    ...etc
</menu>
abb_selectedIndex Define the default selected tab index.
abb_selectedTabId Define the default selected tab by its ID, for example @id/tab_id

Tab appearance

Attribute Description Default
abb_selectedTabType Determines whether the icon or text should be shown when a tab has been selected.

icon

text

icon
abb_tabColor The color of the icon or text when the tab is not selected. @color/textColorPrimary
abb_tabColorSelected The color of the icon or text when the tab is selected. @color/colorPrimary
abb_tabColorDisabled The color of the icon or text whenever the tab has been disabled. @color/textColorSecondary
abb_textAppearance Customize the look and feel of text in tabs, down below is an example of a custom text appearance.

Define a new style in res/values/styles.xml:
<style name="CustomText">
    <item name="android:textAllCaps">true</item>
    <item name="android:fontFamily">serif</item>
    <item name="android:textSize">16sp</item>
    <item name="android:textStyle">italic|bold</item>
</style>
abb_textStyle Style (normal, bold, italic, bold|italic) for the text.

Use bottom_bar.typeface to programmatically set text style.
normal
abb_textSize Size of the text. Recommended dimension type for text is "sp" (scaled-pixels), for example: 14sp. 14sp
abb_iconSize Increase or decrease the size of the icon. 24dp
abb_rippleEnabled Enables the 'ripple' effect when selecting a tab.

false
abb_rippleColor Change the color of the aforementioned ripple effect. Default theme color

Badges

Attribute Description Default
abb_badgeBackgroundColor The background color of the badges. #ff0c10 (red)
abb_badgeTextColor The text color of the text inside the badges. #FFFFFF
abb_badgeTextSize The text size of the text inside the badges. Recommended dimension type for text is "sp" (scaled-pixels), for example: 14sp. 10sp
abb_badgeAnimation The enter and exit animation type for badges.

none
scale
fade
scale
abb_badgeAnimationDuration The duration of the entry and exit animation of a badge. 150

Animations

Attribute Description Default
abb_animationDuration The duration of all animations, including the indicator animation. 400
abb_tabAnimation The enter and exit animation style of the tabs which are not selected.

none

slide

fade

fade
abb_tabAnimationSelected The enter and exit animation style of the selected tab.

none

slide

fade

slide
abb_animationInterpolator The interpolator used for all animations.

See "Android Interpolators: A Visual Guide" for more information on available interpolators.

Example value: @android:anim/overshoot_interpolator
FastOutSlowInInterpolator

Indicator

Attribute Description Default
abb_indicatorColor The color of the indicator. @android/colorPrimary
abb_indicatorHeight The height of the indicator. 3dp
abb_indicatorMargin The horizontal margin of the indicator. This determines the width of the indicator. 0dp
abb_indicatorAppearance Configure the shape of the indicator either to be square or round.

invisible

square

round

square
abb_indicatorLocation Configure the location of the selected tab indicator, top, bottom or invisible.

top

bottom

top
abb_indicatorAnimation The animation type of the indicator when changing the selected tab.

none


slide

fade
slide

Featured in

Credits

License

MIT License

Copyright (c) 2021 Joery Droppers (https://github.com/Droppers)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

animatedbottombar's People

Contributors

am3n avatar droppers avatar mbobiosio avatar pelmenstar1 avatar rosuh avatar sinadalvand 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

animatedbottombar's Issues

unexpected resource type : 'menu' expected string

there is a red error message when using AnimatedBottomBar

in android studio, in Design tab, app_tabs field gets red with this error message: "unexpected resource type : 'menu' expected string"

but it works fine anyway...

Feature request

I have n number of tab which are not fit in screen so I need to make horizontal scrallable tabs.
But in current version we can't make horizontal scrallable tabs.

Please add this kind of feature.

WhatsApp Image 2022-07-31 at 7 34 30 PM

setNestedScrollingEnabled is not respected

It currently intercepts all touch events in a nested scrollview. This is difficult to configure since setNestedScrollingEnabled is ignored, when calling this method the value should also be set for the inner RecyclerView.

Temporary workaround using reflection:

val field = bottom_bar.javaClass.getDeclaredField("recycler")
field.isAccessible = true

val recycler = field.get(bottom_bar) as RecyclerView
recycler.isNestedScrollingEnabled = false

Download Error

Could not find constraintlayout-solver-2.0.2.jar (androidx.constraintlayout:constraintlayout-solver:2.0.2).

All icons disappears when i set badge twice

In the activity's onResume function I added code to check badge every time activity rersumes:

if (badgeNumber > 0) bn_menu.setBadgeAtTabIndex(1, AnimatedBottomBar.Badge("$badgeNumber")) else bn_menu.clearBadgeAtTabIndex(1)

So this code caused an issue to the users.
i improved it to be like this and the issue was solved:

val notifTab = bn_menu.tabs[1] if (badgeNumber > 0) { if (notifTab.badge == null) { bn_menu.setBadgeAtTab(notifTab, AnimatedBottomBar.Badge("$badgeNumber")) } } else { if(notifTab.badge != null) { bn_menu.clearBadgeAtTab(notifTab) } }

But the issue here that the badge is not updated once it is added. Only cleared if badge is 0.

I think those checks must be done inside the library, like if I call clearBadgeAtTab or setBadgeAtTab(notifTab, AnimatedBottomBar.Badge("$badgeNumber")) twice It must not hide all icons.

I try to run DEMO, but there is an error in the execution.

I downloaded the source file.
I try to run DEMO, but there is an error in the execution.

Please see the error message below and give us some advice to carry out the demonstration.

Thank you.

error message ------------------------------------------------

E/AndroidRuntime: FATAL EXCEPTION: main
Process: nl.joery.demo.animatedbottombar, PID: 2834
java.lang.RuntimeException: Unable to start activity ComponentInfo{nl.joery.demo.animatedbottombar/nl.joery.demo.animatedbottombar.playground.PlaygroundActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class nl.joery.animatedbottombar.AnimatedBottomBar
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2378)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2440)
at android.app.ActivityThread.access$800(ActivityThread.java:162)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1348)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5422)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:914)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class nl.joery.animatedbottombar.AnimatedBottomBar
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:696)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170)
at nl.joery.demo.animatedbottombar.playground.PlaygroundActivity.onCreate(PlaygroundActivity.kt:34)
at android.app.Activity.performCreate(Activity.java:6057)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2331)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2440) 
at android.app.ActivityThread.access$800(ActivityThread.java:162) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1348) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5422) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:914) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:696) 
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170) 
at nl.joery.demo.animatedbottombar.playground.PlaygroundActivity.onCreate(PlaygroundActivity.kt:34) 
at android.app.Activity.performCreate(Activity.java:6057) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2331) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2440) 
at android.app.ActivityThread.access$800(ActivityThread.java:162) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1348) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5422) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:914) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707) 
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f07005f
at android.content.res.Resources.getValue(Resources.java:1316)
at android.content.res.Resources.getDrawable(Resources.java:812)
at android.content.Context.getDrawable(Context.java:403)
at com.android.internal.view.menu.MenuItemImpl.getIcon(MenuItemImpl.java:388)
at nl.joery.animatedbottombar.utils.MenuParser.parse(MenuParser.kt:22)
at nl.joery.animatedbottombar.AnimatedBottomBar.initInitialTabs(AnimatedBottomBar.kt:272)
at nl.joery.animatedbottombar.AnimatedBottomBar.initAttributes(AnimatedBottomBar.kt:221)
at nl.joery.animatedbottombar.AnimatedBottomBar.(AnimatedBottomBar.kt:54)
at nl.joery.animatedbottombar.AnimatedBottomBar.(AnimatedBottomBar.kt:31)
at nl.joery.animatedbottombar.AnimatedBottomBar.(AnimatedBottomBar.kt)
at java.lang.reflect.Constructor.newInstance(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
at android.view.LayoutInflater.createView(LayoutInflater.java:607) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:696) 
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170) 
at nl.joery.demo.animatedbottombar.playground.PlaygroundActivity.onCreate(PlaygroundActivity.kt:34) 
at android.app.Activity.performCreate(Activity.java:6057) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2331) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2440) 
at android.app.ActivityThread.access$800(ActivityThread.java:162) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1348) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5422) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:914) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707) 

What is the latest version?

The version I download and look at is different if I look at the source on the Github

For example, the version downloaded to the Library has a layout folder, but if you look at the source in the Github Webstore, there is no layout folder.

Which version is the latest?

Min height

It is not a truble, but ... Maybe 64dp too large?

How to use Fragment with this library

How do we use fragment with this library? Let say i want to change FrameLayout with fragmentLayout base on position. Let say when we on Home, so my FrameLayout change to fragment_home. Is it possible to use switch case programatically?

duplicate class error

Duplicate class androidx.navigation.ActivityKt found in modules navigation-runtime-2.5.2-runtime (androidx.navigation:navigation-runtime:2.5.2) and navigation-runtime-ktx-2.3.5-runtime (androidx.navigation:navigation-runtime-ktx:2.3.5)
Duplicate class androidx.navigation.ActivityNavArgsLazyKt found in modules navigation-runtime-2.5.2-runtime (androidx.navigation:navigation-runtime:2.5.2) and navigation-runtime-ktx-2.3.5-runtime (androidx.navigation:navigation-runtime-ktx:2.3.5)
Duplicate class androidx.navigation.ActivityNavArgsLazyKt$navArgs$1 found in modules navigation-runtime-2.5.2-runtime (androidx.navigation:navigation-runtime:2.5.2) and navigation-runtime-ktx-2.3.5-runtime (androidx.navigation:navigation-runtime-ktx:2.3.5)
Duplicate class androidx.navigation.ActivityNavigatorDestinationBuilder found in modules navigation-runtime-2.5.2-runtime (androidx.navigation:navigation-runtime:2.5.2) and navigation-runtime-ktx-2.3.5-runtime (androidx.navigation:navigation-runtime-ktx:2.3.5)
Duplicate class androidx.navigation.ActivityNavigatorDestinationBuilderKt found in modules navigation-runtime-2.5.2-runtime (androidx.navigation:navigation-runtime:2.5.2) and navigation-runtime-ktx-2.3.5-runtime (androidx.navigation:navigation-runtime-ktx:2.3.5)
Duplicate class androidx.navigation.ActivityNavigatorExtrasKt found in modules navigation-runtime-2.5.2-runtime (androidx.navigation:navigation-runtime:2.5.2) and navigation-runtime-ktx-2.3.5-runtime (androidx.navigation:navigation-runtime-ktx:2.3.5)
Duplicate class androidx.navigation.AnimBuilder found in modules navigation-common-2.5.2-runtime (androidx.navigation:navigation-common:2.5.2) and navigation-common-ktx-2.3.5-runtime (androidx.navigation:navigation-common-ktx:2.3.5)
Duplicate class androidx.navigation.NavActionBuilder found in modules navigation-common-2.5.2-runtime (androidx.navigation:navigation-common:2.5.2) and navigation-common-ktx-2.3.5-runtime (androidx.navigation:navigation-common-ktx:2.3.5)
Duplicate class androidx.navigation.NavArgsLazy found in modules navigation-common-2.5.2-runtime (androidx.navigation:navigation-common:2.5.2) and navigation-common-ktx-2.3.5-runtime (androidx.navigation:navigation-common-ktx:2.3.5)
Duplicate class androidx.navigation.NavArgsLazyKt found in modules navigation-common-2.5.2-runtime (androidx.navigation:navigation-common:2.5.2) and navigation-common-ktx-2.3.5-runtime (androidx.navigation:navigation-common-ktx:2.3.5)
Duplicate class androidx.navigation.NavArgumentBuilder found in modules navigation-common-2.5.2-runtime (androidx.navigation:navigation-common:2.5.2) and navigation-common-ktx-2.3.5-runtime (androidx.navigation:navigation-common-ktx:2.3.5)
Duplicate class androidx.navigation.NavControllerKt found in modules navigation-runtime-2.5.2-runtime (androidx.navigation:navigation-runtime:2.5.2) and navigation-runtime-ktx-2.3.5-runtime (androidx.navigation:navigation-runtime-ktx:2.3.5)
Duplicate class androidx.navigation.NavDeepLinkDsl found in modules navigation-common-2.5.2-runtime (androidx.navigation:navigation-common:2.5.2) and navigation-common-ktx-2.3.5-runtime (androidx.navigation:navigation-common-ktx:2.3.5)
Duplicate class androidx.navigation.NavDeepLinkDslBuilder found in modules navigation-common-2.5.2-runtime (androidx.navigation:navigation-common:2.5.2) and navigation-common-ktx-2.3.5-runtime (androidx.navigation:navigation-common-ktx:2.3.5)
Duplicate class androidx.navigation.NavDeepLinkDslBuilderKt found in modules navigation-common-2.5.2-runtime (androidx.navigation:navigation-common:2.5.2) and navigation-common-ktx-2.3.5-runtime (androidx.navigation:navigation-common-ktx:2.3.5)
Duplicate class androidx.navigation.NavDestinationBuilder found in modules navigation-common-2.5.2-runtime (androidx.navigation:navigation-common:2.5.2) and navigation-common-ktx-2.3.5-runtime (androidx.navigation:navigation-common-ktx:2.3.5)
Duplicate class androidx.navigation.NavDestinationDsl found in modules navigation-common-2.5.2-runtime (androidx.navigation:navigation-common:2.5.2) and navigation-common-ktx-2.3.5-runtime (androidx.navigation:navigation-common-ktx:2.3.5)
Duplicate class androidx.navigation.NavGraphBuilder found in modules navigation-common-2.5.2-runtime (androidx.navigation:navigation-common:2.5.2) and navigation-common-ktx-2.3.5-runtime (androidx.navigation:navigation-common-ktx:2.3.5)
Duplicate class androidx.navigation.NavGraphBuilderKt found in modules navigation-common-2.5.2-runtime (androidx.navigation:navigation-common:2.5.2) and navigation-common-ktx-2.3.5-runtime (androidx.navigation:navigation-common-ktx:2.3.5)
Duplicate class androidx.navigation.NavGraphKt found in modules navigation-common-2.5.2-runtime (androidx.navigation:navigation-common:2.5.2) and navigation-common-ktx-2.3.5-runtime (androidx.navigation:navigation-common-ktx:2.3.5)
Duplicate class androidx.navigation.NavHostKt found in modules navigation-runtime-2.5.2-runtime (androidx.navigation:navigation-runtime:2.5.2) and navigation-runtime-ktx-2.3.5-runtime (androidx.navigation:navigation-runtime-ktx:2.3.5)
Duplicate class androidx.navigation.NavOptionsBuilder found in modules navigation-common-2.5.2-runtime (androidx.navigation:navigation-common:2.5.2) and navigation-common-ktx-2.3.5-runtime (androidx.navigation:navigation-common-ktx:2.3.5)
Duplicate class androidx.navigation.NavOptionsBuilderKt found in modules navigation-common-2.5.2-runtime (androidx.navigation:navigation-common:2.5.2) and navigation-common-ktx-2.3.5-runtime (androidx.navigation:navigation-common-ktx:2.3.5)
Duplicate class androidx.navigation.NavOptionsDsl found in modules navigation-common-2.5.2-runtime (androidx.navigation:navigation-common:2.5.2) and navigation-common-ktx-2.3.5-runtime (androidx.navigation:navigation-common-ktx:2.3.5)
Duplicate class androidx.navigation.NavigatorProviderKt found in modules navigation-common-2.5.2-runtime (androidx.navigation:navigation-common:2.5.2) and navigation-common-ktx-2.3.5-runtime (androidx.navigation:navigation-common-ktx:2.3.5)
Duplicate class androidx.navigation.PopUpToBuilder found in modules navigation-common-2.5.2-runtime (androidx.navigation:navigation-common:2.5.2) and navigation-common-ktx-2.3.5-runtime (androidx.navigation:navigation-common-ktx:2.3.5)
Duplicate class androidx.navigation.ViewKt found in modules navigation-runtime-2.5.2-runtime (androidx.navigation:navigation-runtime:2.5.2) and navigation-runtime-ktx-2.3.5-runtime (androidx.navigation:navigation-runtime-ktx:2.3.5)
Duplicate class androidx.navigation.ui.ActivityKt found in modules navigation-ui-2.5.2-runtime (androidx.navigation:navigation-ui:2.5.2) and navigation-ui-ktx-2.3.5-runtime (androidx.navigation:navigation-ui-ktx:2.3.5)
Duplicate class androidx.navigation.ui.AppBarConfigurationKt found in modules navigation-ui-2.5.2-runtime (androidx.navigation:navigation-ui:2.5.2) and navigation-ui-ktx-2.3.5-runtime (androidx.navigation:navigation-ui-ktx:2.3.5)
Duplicate class androidx.navigation.ui.AppBarConfigurationKt$AppBarConfiguration$1 found in modules navigation-ui-2.5.2-runtime (androidx.navigation:navigation-ui:2.5.2) and navigation-ui-ktx-2.3.5-runtime (androidx.navigation:navigation-ui-ktx:2.3.5)
Duplicate class androidx.navigation.ui.AppBarConfigurationKt$AppBarConfiguration$2 found in modules navigation-ui-2.5.2-runtime (androidx.navigation:navigation-ui:2.5.2) and navigation-ui-ktx-2.3.5-runtime (androidx.navigation:navigation-ui-ktx:2.3.5)
Duplicate class androidx.navigation.ui.AppBarConfigurationKt$AppBarConfiguration$3 found in modules navigation-ui-2.5.2-runtime (androidx.navigation:navigation-ui:2.5.2) and navigation-ui-ktx-2.3.5-runtime (androidx.navigation:navigation-ui-ktx:2.3.5)
Duplicate class androidx.navigation.ui.AppBarConfigurationKt$sam$i$androidx_navigation_ui_AppBarConfiguration_OnNavigateUpListener$0 found in modules navigation-ui-2.5.2-runtime (androidx.navigation:navigation-ui:2.5.2) and navigation-ui-ktx-2.3.5-runtime (androidx.navigation:navigation-ui-ktx:2.3.5)
Duplicate class androidx.navigation.ui.BottomNavigationViewKt found in modules navigation-ui-2.5.2-runtime (androidx.navigation:navigation-ui:2.5.2) and navigation-ui-ktx-2.3.5-runtime (androidx.navigation:navigation-ui-ktx:2.3.5)
Duplicate class androidx.navigation.ui.CollapsingToolbarLayoutKt found in modules navigation-ui-2.5.2-runtime (androidx.navigation:navigation-ui:2.5.2) and navigation-ui-ktx-2.3.5-runtime (androidx.navigation:navigation-ui-ktx:2.3.5)
Duplicate class androidx.navigation.ui.MenuItemKt found in modules navigation-ui-2.5.2-runtime (androidx.navigation:navigation-ui:2.5.2) and navigation-ui-ktx-2.3.5-runtime (androidx.navigation:navigation-ui-ktx:2.3.5)
Duplicate class androidx.navigation.ui.NavControllerKt found in modules navigation-ui-2.5.2-runtime (androidx.navigation:navigation-ui:2.5.2) and navigation-ui-ktx-2.3.5-runtime (androidx.navigation:navigation-ui-ktx:2.3.5)
Duplicate class androidx.navigation.ui.NavigationViewKt found in modules navigation-ui-2.5.2-runtime (androidx.navigation:navigation-ui:2.5.2) and navigation-ui-ktx-2.3.5-runtime (androidx.navigation:navigation-ui-ktx:2.3.5)
Duplicate class androidx.navigation.ui.ToolbarKt found in modules navigation-ui-2.5.2-runtime (androidx.navigation:navigation-ui:2.5.2) and navigation-ui-ktx-2.3.5-runtime (androidx.navigation:navigation-ui-ktx:2.3.5)

Go to the documentation to learn how to Fix dependency resolution errors.

does not have a NavController set

hi, how can use setupWithNavController? i want use your lib but also share data between fragments, I will be glad you help

this my mainacitivity

1

this error

2

Add function to set icons programatically

It would be great to have the feature to set icons for the bottom bar programmatically as it would mean that any third party libraries such as Android Iconics can be utilised so that drawable resources do not have to be used in XML and can be created programmatically instead.

bottomBar.tabs[i].icon = customIcon currently says Val cannot be reassigned.

This problem occurs when migrating to a project

The following classes could not be instantiated:
- nl.joery.animatedbottombar.AnimatedBottomBar (Open Class, Show Exception, Clear Cache)
Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE. If this is an unexpected error you can also try to build the project, then manually refresh the layout. Exception Details java.lang.IllegalArgumentException: Unknown color   at android.graphics.Color.parseColor(Color.java:1391)   at com.android.layoutlib.bridge.android.BridgeContext.resolveThemeAttribute(BridgeContext.java:412)   at android.content.res.Resources_Theme_Delegate.resolveAttribute(Resources_Theme_Delegate.java:97)   at android.content.res.Resources$Theme.resolveAttribute(Resources.java:1578)   at nl.joery.animatedbottombar.ExtensionsKt.getTextColor(Extensions.kt:20)   at nl.joery.animatedbottombar.AnimatedBottomBar.initAttributes(AnimatedBottomBar.kt:57)   at nl.joery.animatedbottombar.AnimatedBottomBar.(AnimatedBottomBar.kt:50)   at nl.joery.animatedbottombar.AnimatedBottomBar.(AnimatedBottomBar.kt:27)   at nl.joery.animatedbottombar.AnimatedBottomBar.(AnimatedBottomBar.kt:-1)   at java.lang.reflect.Constructor.newInstance(Constructor.java:423)   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)   at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:863)   at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)   at android.view.LayoutInflater.rInflate(LayoutInflater.java:837)   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)   at android.view.LayoutInflater.inflate(LayoutInflater.java:515)

Disable tabs

Hi! I have just tried your lib in an application and, although I know we can intercept some tabs with the OnTabInterceptedListener, I would love to have the possibility to completely disable some tabs, preventing the user to click on them and displaying the icon with another color (i.e, in my application the icons are shown in blue and the disabled ones in grey).

In my application, the users need to complete some data to advance to the next section, so it would be great to only enable those tabs when the data is completed.

Could it be possible to implement this feature?

Thanks a lot!!!

add scroll feature

nice if can add a scroll feature when there are more than 4 tabs,this can make the tab flexible for tab names with long character

Feature Request

You have 2 Options for Text and Icon, What can you add 2 more:

Text and Text
Icon and Icon

So people can choose if I just want icon.

Also maybe add a new variation,
Icon with Text On Top or Bottom.

Options can be TextIcon

app:abb_selectedTabType="text/icon/both/icononly/textonly/both"
app:abb_TextLocation="top/bottom"

method setOnTabSelectListener() error

Hi. I,m new on android and i want to use this library and i got these errors when use 1.0.5+ version of this library.

Code that got error:

animatedBottomBar.setOnTabSelectListener(new AnimatedBottomBar.OnTabSelectListener() {
@OverRide
public void onTabSelected(int lastIndex, @nullable AnimatedBottomBar.Tab lastTab, int newIndex, @NotNull AnimatedBottomBar.Tab newTab) {
Fragment fragment = null;
switch (newTab.getId()) {
case R.id.home:
fragment = new HomeFragment();
break;
case R.id.dashboard:
fragment = new DashboardFragment();
break;
case R.id.settings:
fragment = new SettingsFragment();
break;
}
if (fragment != null) {
fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.fragment_container, fragment)
.commit();
} else {
Log.e(TAG, "Error in creating Fragment");
}

Build error:

C:\Users\mohammadreza22\AndroidStudioProjects\EnergX\app\src\main\java\com\madeit\energx\MainActivity.java:34: error: <anonymous com.madeit.energx.MainActivity$1> is not abstract and does not override abstract method onTabReselected(int,Tab) in OnTabSelectListener
animatedBottomBar.setOnTabSelectListener(new AnimatedBottomBar.OnTabSelectListener() {

Logcat:

2020-04-22 01:34:14.855 7369-7369/com.madeit.energx E/m.madeit.energ: Invalid ID 0x00000975.
2020-04-22 01:34:14.874 7369-7369/com.madeit.energx E/m.madeit.energ: Invalid ID 0x00000974.
2020-04-22 01:34:14.875 7369-7369/com.madeit.energx E/m.madeit.energ: No package ID ff found for ID 0xff2196f3.
2020-04-22 01:34:14.876 7369-7369/com.madeit.energx D/AndroidRuntime: Shutting down VM
2020-04-22 01:34:14.945 7369-7369/com.madeit.energx E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.madeit.energx, PID: 7369
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.madeit.energx/com.madeit.energx.MainActivity}: android.view.InflateException: Binary XML file line #8 in com.madeit.energx:layout/activity_main: Binary XML file line #8 in com.madeit.energx:layout/activity_main: Error inflating class nl.joery.animatedbottombar.AnimatedBottomBar
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3333)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3477)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2043)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7464)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:955)
Caused by: android.view.InflateException: Binary XML file line #8 in com.madeit.energx:layout/activity_main: Binary XML file line #8 in com.madeit.energx:layout/activity_main: Error inflating class nl.joery.animatedbottombar.AnimatedBottomBar
Caused by: android.view.InflateException: Binary XML file line #8 in com.madeit.energx:layout/activity_main: Error inflating class nl.joery.animatedbottombar.AnimatedBottomBar
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:852)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1004)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:959)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1121)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
at android.view.LayoutInflater.inflate(LayoutInflater.java:680)
at android.view.LayoutInflater.inflate(LayoutInflater.java:532)
at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.madeit.energx.MainActivity.onCreate(MainActivity.java:12)
at android.app.Activity.performCreate(Activity.java:7990)
at android.app.Activity.performCreate(Activity.java:7979)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3308)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3477)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2043)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7464)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:955)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0xff2196f3
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:239)
at android.content.res.Resources.getColor(Resources.java:1016)
2020-04-22 01:34:14.945 7369-7369/com.madeit.energx E/AndroidRuntime: at android.content.Context.getColor(Context.java:676)
at androidx.core.content.ContextCompat.getColor(ContextCompat.java:514)
at nl.joery.animatedbottombar.ExtensionsKt.getColorResCompat(Extensions.kt:14)
at nl.joery.animatedbottombar.AnimatedBottomBar.initAttributes(AnimatedBottomBar.kt:61)
at nl.joery.animatedbottombar.AnimatedBottomBar.(AnimatedBottomBar.kt:50)
at nl.joery.animatedbottombar.AnimatedBottomBar.(AnimatedBottomBar.kt:27)
at nl.joery.animatedbottombar.AnimatedBottomBar.(Unknown Source:6)
... 28 more

Configuration change resets bottom bar position

Selecting a different tab from the default and then changing the theme will reset the current tab selection. This means that it will be out of sync with the ViewPager. The tab selection should be maintained even after configuration changes - I have attached a video to show this.

21-08-18-17-48-56.mp4

Add Support for NavController

Hello, I really like the design of your library, and I was wondering if you could add the ability to easily set it up with a NavController, as the library I was previously using, ibrahimsn98/SmoothBottomBar, has this functionality. I found how they implemented it, and was able to modify their code to work with your library. I have included the file I modified instead of trying to create a fork of your library, as I am not familiar with how your library works internally.
I don't know if this helps, but I belive this is how they used the NavigationComponentHelper in their main class:

    fun setupWithNavController(menu: Menu, navController: NavController){
        NavigationComponentHelper.setupWithNavController(menu,this,navController)
    }

Thank you for considering this!
NavigationComponentHelper.txt

What is the role of the setEnabled() method in the Badge Class?

What is the role of the setEnabled() method in the Badge Class?

` override fun setEnabled(enabled: Boolean) {
val lastEnabled = isEnabled
super.setEnabled(enabled)

    if (lastEnabled == enabled) {
        return
    }

    if (animationType == AnimatedBottomBar.BadgeAnimation.NONE) {
        visibility = if (enabled) VISIBLE else GONE
        return
    }

    animator.run {
        duration = _animationDuration.toLong()

        if(isEnabled) {
            start()
        } else {
            reverse()
        }
    }
}`

TABS/MENU NOT SHOWING

The tabs and menu is not showing, i even tried to just copy the default code in README but its not working, I also tried the version 1.0.4 to 1.0.8 but not working

Fatal Exception: java.lang.IllegalStateException

`Fatal Exception: java.lang.IllegalStateException
newView must not be null

nl.joery.animatedbottombar.TabIndicator.setSelectedIndex (TabIndicator.kt:161)
nl.joery.animatedbottombar.AnimatedBottomBar$initAdapter$1.invoke (AnimatedBottomBar.kt:184)
nl.joery.animatedbottombar.AnimatedBottomBar$initAdapter$1.invoke (AnimatedBottomBar.kt:23)
nl.joery.animatedbottombar.TabAdapter.selectTab (TabAdapter.kt:104)
nl.joery.animatedbottombar.AnimatedBottomBar.selectTab (AnimatedBottomBar.kt:373)
nl.joery.animatedbottombar.AnimatedBottomBar.selectTabAt (AnimatedBottomBar.kt:353)
nl.joery.animatedbottombar.AnimatedBottomBar.selectTabAt$default (AnimatedBottomBar.kt:347)
nl.joery.animatedbottombar.AnimatedBottomBar$setupWithViewPager2$1.onPageSelected (AnimatedBottomBar.kt:426)`

I use AnimatedBottomBar with ViewPager2. I have only 2 tabs. Select second and rotate device.

ps by the way, demo.apk is not exist and your demo is not compiling. please, take a look.

Can't use it with a Navigation component

I tried to use this bottom bar with Navigation component, tried to tie the items with fraagments using a NavController but i can't set up this bottom bar with it!

Bottom Navigation does not work with Navigation Components

Issues

  • Bottom Navigation is not working correctly with Navigation Components
  • Fragment is not changing when bottom nav item is pressed
  • Sample code shown in the NavControllerActivity is wrong
  • No Documentation regarding configuration with Navigation Components in README.md

android.view.InflateException

My app is crashing when i applied this library, i tried to create a new project following the readME.md settings but keeps showing me this error:

2020-06-08 06:39:44.178 9236-9236/com.example.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.myapplication, PID: 9236
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class nl.joery.animatedbottombar.AnimatedBottomBar
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2895)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1616)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
Caused by: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class nl.joery.animatedbottombar.AnimatedBottomBar
Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class nl.joery.animatedbottombar.AnimatedBottomBar
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:651)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:867)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
at android.view.LayoutInflater.inflate(LayoutInflater.java:519)
at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.example.myapplication.MainActivity.onCreate(MainActivity.java:12)
at android.app.Activity.performCreate(Activity.java:7088)
at android.app.Activity.performCreate(Activity.java:7079)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2895)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1616)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
Caused by: java.lang.Exception: Menu item attribute 'icon' for tab named 'Home' is missing
at nl.joery.animatedbottombar.MenuParser.parse(MenuParser.kt:22)
at nl.joery.animatedbottombar.AnimatedBottomBar.initInitialTabs(AnimatedBottomBar.kt:240)
at nl.joery.animatedbottombar.AnimatedBottomBar.initAttributes(AnimatedBottomBar.kt:190)
at nl.joery.animatedbottombar.AnimatedBottomBar.(AnimatedBottomBar.kt:50)
at nl.joery.animatedbottombar.AnimatedBottomBar.(AnimatedBottomBar.kt:27)
at nl.joery.animatedbottombar.AnimatedBottomBar.(Unknown Source:6)
at java.lang.reflect.Constructor.newInstance0(Native Method)聽
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)聽
at android.view.LayoutInflater.createView(LayoutInflater.java:651)聽
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)聽
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)聽
at android.view.LayoutInflater.rInflate(LayoutInflater.java:867)聽
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)聽
at android.view.LayoutInflater.inflate(LayoutInflater.java:519)聽
at android.view.LayoutInflater.inflate(LayoutInflater.java:427)聽
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)聽
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)聽
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)聽
at com.example.myapplication.MainActivity.onCreate(MainActivity.java:12)聽
at android.app.Activity.performCreate(Activity.java:7088)聽
at android.app.Activity.performCreate(Activity.java:7079)聽
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)聽
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)聽
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2895)聽
at android.app.ActivityThread.-wrap11(Unknown Source:0)聽
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1616)聽
at android.os.Handler.dispatchMessage(Handler.java:106)聽
at android.os.Looper.loop(Looper.java:176)聽
at android.app.ActivityThread.main(ActivityThread.java:6651)聽
at java.lang.reflect.Method.invoke(Native Method)聽
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)聽
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)聽

How to use fragment with whis AnimatedBottomBar

How do we use fragment with this library? Let say i want to change FrameLayout with fragmentLayout base on position. Let say when we on Home, so my FrameLayout change to fragment_home. Is it possible to use switch case programatically?

Allow to reset selection

I have a use case where when the user selects a tab, a certain view would show. then if the user reselects that tab that view would disappear, but I can't find a way to deselect the tab or reset the selection.

I managed to handle this using this useful callback:

mainBar.onTabReselected = { tab ->
                when (tab?.id) {
                    R.id.fontSize -> {
                        seekBarView.reverseVisibility()
                         //  mainBar.resetSelection()   or   tab.deselect()
                    }
                   // other code
                }
            }

Resource not found exception when an attirube doesn't refer to a color that is in colors.xml

Hi, firstly thank you so much for this great library!

I wanna mention about an important problem. I got the following error when I use AnimatedBottomBar:

109045175-51af5c00-76e4-11eb-836c-3f79fafb3205

App is stoping in the following lines when we track the code:
tabColorSelected = context.getColorResCompat(android.R.attr.colorPrimary)

After hours of investigation, I understood the reason of the problem. I changed color attribute in my theme as below:

image

And it worked! We must use color attribute instead of writing the color like #526fa4.

Did you do that intentionally? If yes, could you pleasee write a note about it in the readme. So that other people don't waste time like me to fix this problem :(

This library does NOT work with androidx.appcompat:appcompat:1.5.0

by upgrading to androidx.appcompat:appcompat:1.5.0
it cause this error:
org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction

it works by androidx.appcompat:appcompat:1.4.2 fine but NOT 1.5.0

Icon padding?

Hi, thinking about using this library for my app, but supplying a bottom bar with png drawables makes the icons look big and distasteful. Is there an option to add padding or margin for icons in xml? Thanks

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.