Remove BottomNavigationView 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.
BottomNavigationView: How to remove hypheanted labels
As 5 items might be a lot of space, it is necessary to compromise text size. In order to fix it, adding a custom style to the BottomNavigationView text gets the job done:
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
...
app:itemTextAppearanceActive="@style/navTextActive"
app:itemTextAppearanceInactive="@style/navTextInactive"/>
on styles.xml:
<style name="navTextInactive">
<item name="android:textSize">11sp</item>
</style>
<style name="navTextActive">
<item name="android:textSize">12sp</item>
</style>
Result:
FixedNavBar
Hope it can help anyone out there!
How to remove title from bottom navigation
I use variations of the below code to customize the labels of BottomNavigationView
which are essentially TextViews:
private void removeBottomNavigationLabels(BottomNavigationView bottomNavigationView) {
for (int i = 0; i < bottomNavigationView.getChildCount(); i++) {
View item = bottomNavigationView.getChildAt(i);
if (item instanceof BottomNavigationMenuView) {
BottomNavigationMenuView menu = (BottomNavigationMenuView) item;
for (int j = 0; j < menu.getChildCount(); j++) {
View menuItem = menu.getChildAt(j);
View small = menuItem.findViewById(android.support.design.R.id.smallLabel);
if (small instanceof TextView) {
((TextView) small).setVisibility(View.GONE);
}
View large = menuItem.findViewById(android.support.design.R.id.largeLabel);
if (large instanceof TextView) {
((TextView) large).setVisibility(View.GONE);
}
}
}
}
BottomNavigationMenuView menuView = (BottomNavigationMenuView) bottomNavigationView.getChildAt(0);
for (int i = 0; i < menuView.getChildCount(); i++) {
final View iconView = menuView.getChildAt(i).findViewById(android.support.design.R.id.icon);
iconView.setPadding(0, 40, 0, 0);
ViewGroup.LayoutParams layoutParams = iconView.getLayoutParams();
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
layoutParams.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, displayMetrics);
layoutParams.width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, displayMetrics);
iconView.setLayoutParams(layoutParams);
}
}
You can call it like this:
removeBottomNavigationLabels(yourBottomNavigationView);
You could also try similarly to change the visibility, padding or height of the TextViews.
Remove bottom navigation view text in android
set "app:labelVisibilityMode" with "unlabeled"
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:labelVisibilityMode="unlabeled"/>
Flutter - How to hide/remove title of BottomNavigationBarItem
There are two workarounds for this problem, as this feature is not yet implemented.
- Pass
Container(height: 0.0)
instead ofText("")
- Create widget and use it instead of Flutter's bottom navigation. Source.
Update:
Just add this to your BottomNavigationBar
showSelectedLabels: false,
showUnselectedLabels: false,
BottomNavigationView shows label over icon
Upon closer examination, I found that my default application style Theme.AppCompat.DayNight.DarkActionBar
was causing the problems, and by simultaneously overriding it to Theme.MaterialComponents.DayNight.DarkActionBar
, including overriding the component styles from AppCompat
to MaterialComponents
, I fixed the problem.
Next, I had to add
<item name="bottomNavigationStyle">@style/NavigationViewTheme</item>
to the default style and remove the style call directly in the component.
Remove the top padding in BottomNavigationView
if I understand you true android:layout_height="?attr/actionBarSize"
here you put height as 50dp so try change height to android:layout_height="35dp" or android:layout_height="40dp"
BottomNavigationView display both icons and text labels at all times
For anyone still looking for a solution and doesn't want to rely on third party libraries or runtime reflection, BottomNavigationView in Support Library 28/Jetpack natively supports always having text label.
This is the method you're looking for.
Or in XML, app:labelVisibilityMode="labeled"
Related Topics
Android Image View Matrix Scale + Translate
Android Circular Determinate Progressbar
How to Handle the Firebase Notification When App Is in Foreground
Espresso - How to Check If an Activity Is Launched After Performing a Certain Action
Read Command Output Inside Su Process
Upgraded to Android Studio 3.4 - Aapt2Internalexception: Aapt2: Daemon Startup Failed
How to Ping a Url in an Android Service
Open a PDF File Inside a Webview
Show Toast Widget Underneath a View
Android Studio Create Project Template for New Projects
Add Elevation/Shadow on Toolbar for Pre-Lollipop Devices
Android Set Button Background Programmatically
Android: How to Monitor Wifi Signal Strength
How to Stop Other Apps Playing Music from My Current Activity