Google released new support library v25 with BottomNavigationView
is there any way to remove items labels ?
I hope I am not too late to the party here.
But as of Design Support Library 28.0.0-alpha1 you can use the property
app:labelVisibilityMode="unlabeled"
you can use other values "auto", "labeled" and "selected" as well.
I'd recommend to implement it by yourself as sanf0rd gave in his answer. But AppCompatImageView
is not working for me. I've changed it to ImageView
. And changed getChildAt
to findViewById
.
Also I hide all labels of unselected items.
private void centerMenuIcon() {
BottomNavigationMenuView menuView = getBottomMenuView();
if (menuView != null) {
for (int i = 0; i < menuView.getChildCount(); i++) {
BottomNavigationItemView menuItemView = (BottomNavigationItemView) menuView.getChildAt(i);
TextView smallText = (TextView) menuItemView.findViewById(R.id.smallLabel);
smallText.setVisibility(View.INVISIBLE);
//TextView largeText = (TextView) menuItemView.findViewById(R.id.largeLabel);
ImageView icon = (ImageView) menuItemView.findViewById(R.id.icon);
FrameLayout.LayoutParams params = (LayoutParams) icon.getLayoutParams();
params.gravity = Gravity.CENTER;
menuItemView.setShiftingMode(true);
}
}
}