Cannot get badges to show
See original GitHub issueHi,
Otherwise the NTB works like a charm, but I can’t get the badges to show at all…
Here’s my layout xml: `<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/main_container" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">
<com.gigamole.navigationtabbar.ntb.NavigationTabBar
android:id="@+id/main_ntb"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentTop="true"
app:ntb_animation_duration="200"
app:ntb_active_color="#ffffff"
app:ntb_inactive_color="@color/grey"
app:ntb_badged="true"
app:ntb_titled="false"
app:ntb_scaled="false"
app:ntb_tinted="true"
app:ntb_badge_position="right"
app:ntb_badge_gravity="bottom"
app:ntb_badge_bg_color="@color/theme_red"
app:ntb_badge_title_color="#ffffff"
app:ntb_swiped="true"
app:ntb_bg_color="@color/dark_grey"
app:ntb_badge_size="10sp"
app:ntb_title_size="10sp" />
<io.altru.lack.components.NonSwipeableViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@+id/main_ntb"
android:layout_alignParentBottom="true"
android:background="@color/lightgrey" />
</RelativeLayout>`
Here’s the code for setting up my NTB:
navigationTabBar = (NavigationTabBar) findViewById(R.id.main_ntb);
final ArrayList<NavigationTabBar.Model> models = new ArrayList<>();
IconDrawable browse = new IconDrawable(this, TypiconsIcons.typcn_home_outline).sizeDp(40);
IconDrawable create = new IconDrawable(this, TypiconsIcons.typcn_camera).sizeDp(40);
IconDrawable lists = new IconDrawable(this, TypiconsIcons.typcn_pin).sizeDp(40);
models.add( new NavigationTabBar.Model.Builder(browse, getResources().getColor(R.color.theme_accent)) .build() );
models.add( new NavigationTabBar.Model.Builder(create, getResources().getColor(R.color.theme_accent)) .build() );
models.add( new NavigationTabBar.Model.Builder(lists, getResources().getColor(R.color.theme_accent)) .badgeTitle(“Wee”) .build() );
navigationTabBar.setModels(models);
navigationTabBar.setViewPager(viewPager, 0);
navigationTabBar.setIsBadged(true);
And finally, here’s the code where I try to show the badge (pretty much copied from the sample app):
navigationTabBar.postDelayed(new Runnable() { @Override public void run() { final NavigationTabBar.Model model = navigationTabBar.getModels().get(0); Log.v(TAG, "Is badge showing before: " + model.isBadgeShowed()); model.showBadge(); Log.v(TAG, "Is badge showing after: " + model.isBadgeShowed()); } }, 500);
In the last code snippet, the model.isBadgeShowed() returns false on both calls, both before and after calling model.showBadge()
Any help?
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (5 by maintainers)
Top GitHub Comments
I managed to get the badges and titles to display by wrapping my NavigationTabBar inside a FrameLayout. Perhaps this is a bug with android or the support libraries? In any case, please add this to the description so other people will know in the future. Thanks for your help!
@kaustubhbhagwat can’t say why that would be happening, but I think you will be able to get rid of it by adjusting padding, margin and clip settings or just having a fixed height for both the framelayout and the NTB inside