Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BADGE NOT SHOWED] #137

Open
PaolinoAngeletti opened this issue Feb 12, 2019 · 2 comments
Open

[BADGE NOT SHOWED] #137

PaolinoAngeletti opened this issue Feb 12, 2019 · 2 comments

Comments

@PaolinoAngeletti
Copy link

LAYOUT XML

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Anagrafica"
android:background="@color/light_gray">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/light_gray"
    android:orientation="vertical">

    <include android:id="@+id/toolbar_space" layout="@layout/app_bar_toolbar_large_text"></include>

    <LinearLayout
        android:id="@+id/border"
        android:layout_width="match_parent"
        android:layout_height="4dip"
        android:layout_below="@+id/toolbar_space"
        android:background="@drawable/shadow"
        android:orientation="horizontal"
        android:visibility="visible"></LinearLayout>

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/bottom_bar"
        android:layout_below="@+id/border" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="1dip"
        android:layout_above="@+id/bottom_bar"
        android:background="@drawable/shadow"
        android:orientation="horizontal" />

    <devlight.io.library.ntb.NavigationTabBar
        android:id="@+id/ntb"
        android:layout_width="match_parent"
        android:layout_height="50dip"
        android:layout_above="@+id/bottom_navigation_bar"
        android:layout_alignParentBottom="true"
        app:ntb_active_color="#fff"
        app:ntb_animation_duration="400"
        app:ntb_badge_bg_color="#ffff0000"
        app:ntb_badge_gravity="bottom"
        app:ntb_badge_position="center"
        app:ntb_badge_size="10sp"

        app:ntb_badge_title_color="#ffffffff"
        app:ntb_badged="true"
        app:ntb_bg_color="@color/light_gray"
        app:ntb_icon_size_fraction="0.5"

        app:ntb_inactive_color="@color/light_gray"
        app:ntb_scaled="true"
        app:ntb_swiped="true"
        app:ntb_tinted="true"
        app:ntb_title_mode="all"
        app:ntb_title_size="10sp"
        app:ntb_titled="true" />

    <bottom_menu.BottomNavigationBar
        android:id="@+id/bottom_navigation_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/bottom_bar"
        android:layout_gravity="bottom"
        android:visibility="gone" />

    <com.eightbitlab.bottomnavigationbar.BottomNavigationBar
        android:id="@+id/bottom_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@color/BottomMenuBackground"
        android:visibility="gone"
        app:activeTabColor="@color/MagazzinoPerfetto"
        app:inactiveTabColor="@color/BottomMenuUnselected" />

</RelativeLayout> <!-- Content Page -->

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="@dimen/menu_laterale_width"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="@drawable/bg_form2"
    android:dividerHeight="@dimen/mp_div_height">

    <RelativeLayout
        android:id="@+id/drawerPane"
        android:layout_width="280dp"
        android:layout_height="match_parent"
        android:layout_above="@+id/footer_info"
        android:layout_alignParentStart="false"
        android:layout_alignParentTop="false"
        android:paddingTop="3dip">

        <TextView
            android:id="@+id/email"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/Company"
            android:layout_gravity="bottom"
            android:maxLines="1"
            android:paddingStart="8dip"
            android:text="Data 1"
            android:textColor="#fff"
            android:textSize="@dimen/small_text_size"
            tools:ignore="HardcodedText" />

        <TextView
            android:id="@+id/Company"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:maxLines="1"
            android:paddingStart="8dip"
            android:text="View Profile"
            android:textColor="#fff"
            android:textSize="@dimen/small_text_size"
            tools:ignore="HardcodedText,TooManyViews" />

        <RelativeLayout
            android:id="@+id/profileBox"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/email"
            android:layout_marginTop="3dip"
            android:gravity="left|center_vertical"
            android:padding="8dp">

            <custom.elements.classi_utili.image_view.RoundedImageView
                android:id="@+id/avatar"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:src="@drawable/default_user" />

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="15dp"
                android:layout_toRightOf="@+id/avatar"
                android:orientation="vertical"
                tools:ignore="RtlHardcoded">

                <TextView
                    android:id="@+id/userName"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:maxLines="1"
                    android:text="Rishabh"
                    android:textColor="#fff"
                    android:textSize="@dimen/title_text_size"
                    android:textStyle="bold"
                    tools:ignore="HardcodedText" />

                <TextView
                    android:id="@+id/tipoUtente"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:maxLines="1"
                    android:text="Admin"
                    android:textColor="#fff"
                    android:textSize="@dimen/text_size"
                    tools:ignore="HardcodedText" />

                <TextView
                    android:id="@+id/depositoDefault"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:maxLines="1"
                    android:text="1 - Sirignano"
                    android:textColor="#fff"
                    android:textSize="@dimen/text_size"
                    tools:ignore="HardcodedText" />
            </LinearLayout>
        </RelativeLayout> <!-- Box Profilo -->

        <ListView
            android:id="@+id/navList"
            android:layout_width="280dp"
            android:layout_height="match_parent"
            android:layout_below="@+id/profileBox"
            android:choiceMode="singleChoice" /> <!-- Lista delle opzioni -->

    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/footer_info"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/logoutBtn">

        <TextView
            android:id="@+id/versionName"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentStart="true"
            android:layout_gravity="bottom"
            android:layout_marginStart="5dip"
            android:text="Versione 0.7"
            android:textColor="#fff"
            android:textSize="@dimen/text_size"
            tools:ignore="HardcodedText" />

        <TextView
            android:id="@+id/tvAnnoGestione"
            style="@style/MPTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_marginEnd="5dip"
            android:text="Anno Gestione 2018"
            android:textColor="@android:color/white" />
    </RelativeLayout>

    <Button
        android:id="@+id/logoutBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true"
        android:background="@color/dark_gray"
        android:text="@string/esci"
        android:textColor="@android:color/white"
        android:textSize="20sp"
        android:visibility="visible" />

</RelativeLayout> <!-- Content Menu -->

</android.support.v4.widget.DrawerLayout>

ACTIVITY
final NavigationTabBar navigationTabBar = (NavigationTabBar) findViewById(R.id.ntb);
final ArrayList<NavigationTabBar.Model> models = new ArrayList<>();

    models.add(
            new NavigationTabBar.Model.Builder(
                    getResources().getDrawable(R.drawable.ic_first),
                    R.color.MagazzinoPerfetto
            ).title("Heart")
                    .badgeTitle("NTB")
                    .build()
    );
    models.add(
            new NavigationTabBar.Model.Builder(
                    getResources().getDrawable(R.drawable.ic_second), R.color.MagazzinoPerfetto
            ).badgeTitle("12").build()
    );
    models.add(
            new NavigationTabBar.Model.Builder(
                    getResources().getDrawable(R.drawable.ic_third), R.color.MagazzinoPerfetto
            ).build()
    );
    models.add(
            new NavigationTabBar.Model.Builder(
                    getResources().getDrawable(R.drawable.ic_fourth), R.color.MagazzinoPerfetto
            ).build()
    );

    navigationTabBar.setModels(models);

    //navigationTabBar.setViewPager(viewPager, 2);

    navigationTabBar.setTitleMode(NavigationTabBar.TitleMode.ACTIVE);
    navigationTabBar.setBadgeGravity(NavigationTabBar.BadgeGravity.TOP);
    navigationTabBar.setBadgePosition(NavigationTabBar.BadgePosition.LEFT);
    //navigationTabBar.setTypeface("fonts/custom_font.ttf");
    //navigationTabBar.setIsBadged(true);
    navigationTabBar.setIsTitled(true);
    navigationTabBar.setIsTinted(true);
    //navigationTabBar.setIsBadgeUseTypeface(true);
    navigationTabBar.setBadgeBgColor(Color.RED);
    navigationTabBar.setBadgeTitleColor(Color.WHITE);
    navigationTabBar.setIsSwiped(false);
    navigationTabBar.setBgColor(R.color.light_gray);
    //navigationTabBar.setBadgeSize(30);
    navigationTabBar.setTitleSize(10);
    //navigationTabBar.setIconSizeFraction(-4);
@PaolinoAngeletti
Copy link
Author

I don't find the problem onestly

@duongvanthai
Copy link

duongvanthai commented Sep 18, 2019

Seem NavigationTabBar not show badge if have RelativeLayout is root layout of xml. You can try again with LinearLayout or CoordinatorLayout. :) You can see effect directly badge show in Preview in Android studio if change it to LinearLayout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants