Devlight / NavigationTabBar

Navigation tab bar with colorful interactions.
Apache License 2.0
4.95k stars 857 forks source link

Badges not showing up on #105

Open kaustubhbhagwat opened 7 years ago

kaustubhbhagwat commented 7 years ago

I have already implemented this librry in my project but now i want to show badge notifications but they arent showing up `

      navigationTabBar = findViewById(R.id.ntb);
        final ArrayList<NavigationTabBar.Model> models = new ArrayList<>();
    models.add(
            new NavigationTabBar.Model.Builder(ResourcesCompat.getDrawable(getResources(), R.drawable.news, null), Color.argb(0, 0, 0, 0)).title("messenger").badgeTitle("NTB1")
                    .build()
    );

    models.add(
            new NavigationTabBar.Model.Builder(ResourcesCompat.getDrawable(getResources(), R.drawable.campaigns, null), Color.argb(0, 0, 0, 0)).title("asdas").badgeTitle("NTB2")
                    .build()
    );

    models.add(
            new NavigationTabBar.Model.Builder(ResourcesCompat.getDrawable(getResources(), R.mipmap.ic_connect, null), Color.argb(0, 0, 0, 0)).title("connect").badgeTitle("NTB3")
                    .build()
    );

    models.add(
            new NavigationTabBar.Model.Builder(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_aer_messenger, null), Color.argb(0, 0, 0, 0)).title("messenger").badgeTitle("NTB4")
                    .build()
    );

    models.add(
            new NavigationTabBar.Model.Builder(ResourcesCompat.getDrawable(getResources(), R.drawable.profile, null), Color.argb(0, 0, 0, 0)).title("pro").badgeTitle("NTB5")
                    .build()
    );

    navigationTabBar.setModels(models);

    navigationTabBar.setViewPager(viewPager, 0);
    models.get(1).showBadge();
        navigationTabBar.setTitleMode(NavigationTabBar.TitleMode.ACTIVE);
        navigationTabBar.setIsTinted(true);
//        navigationTabBar.setIsBadgeUseTypeface(true);
//        navigationTabBar.setIsBadged(true);
//        navigationTabBar.setBadgePosition(NavigationTabBar.BadgePosition.CENTER);
//        navigationTabBar.setBadgeBgColor(Color.RED);
        navigationTabBar.setIsSwiped(true);
        navigationTabBar.setBgColor(Color.WHITE);
        navigationTabBar.setIsScaled(false);
        navigationTabBar.setIconSizeFraction(0.5f);      navigationTabBar.setIconSizeFraction(0.5f);
`

this is how i am doing it , but models.get(1).showBadge(); doesnt show up the badges.

`        <com.gigamole.navigationtabbar.ntb.NavigationTabBar
            android:id="@+id/ntb"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            app:ntb_animation_duration="100"
            app:ntb_active_color="@android:color/black"
            app:ntb_inactive_color="@android:color/darker_gray"
            app:ntb_titled="true"
            app:ntb_scaled="true"
            app:ntb_tinted="false"
            app:ntb_title_mode="all"
            app:ntb_swiped="true"
            app:ntb_icon_size_fraction="0.6"
            app:ntb_title_size="10sp"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:elevation="16dp"
            app:ntb_badge_size="12sp"
            app:ntb_badge_bg_color="#ffff0000"
            app:ntb_badge_gravity="top"
            app:ntb_badge_position="left"
            app:ntb_badge_title_color="#ffffffff"
            app:ntb_badge_use_typeface="true"
            app:ntb_badged="true"
            app:ntb_typeface="fonts/agency.ttf"
            />
`

this is my xml file , what am i doing wrong , please help , this is the only thing thats been bothering me for a while now.

Kiran2shaw commented 6 years ago

I had also faced the same issue earlier which got resolved by placing this one line.

navigationTabBar.setIsBadged(true);(As I see that you have commented out the line .) and referring ##this.

Thanks.