-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Long text cutting off in BottomNavigationView #139
Comments
Please add this property in your Xml |
Not sure why this was closed. |
I am also facing this issue. labelVisibilityMode ="labeled" should work too especially if active and inactive text size are the same. Would you mind reconsidering reopening this issue? |
Agreed. I'm not sure why this extra padding is needed in "labeled" mode https://github.com/material-components/material-components-android/blob/master/lib/java/com/google/android/material/bottomnavigation/res/layout/design_bottom_navigation_item.xml#L45 |
Same goes for me. It would be nice to have this fixed... As @t7costa said i'm not sure why did they put an extra padding on the largeLabel... |
As for now I use this for the active childView:
But it is not the ideal, would be nice if we had an official API to influence this. |
Would like this reopened as well. Facing the same issue and it doesn't seem to have a reason that it needs to work this way. @kistitan How did you get the reference to the childView for the above solution? |
This issue is being tracked at https://issuetracker.google.com/issues/115754572 |
Till Google Fixes this, I was able to to use @kistitan 's solution and also add this to the mix to help truncate the text properly in Kotlin: |
Also, we can override these dimens to change the text sizes of the labels in the active and inactive state.
Simply add these in your dimens.xml, so that the default text size will be overridden. |
@kistitan and @kaustavjaiswal's solutions works like a chaaarm, thanks! |
This problem still persists. Add design_bottom_navigation_item.xml from https://github.com/material-components/material-components-android/blob/master/lib/java/com/google/android/material/bottomnavigation/res/layout/design_bottom_navigation_item.xml to your project's layout directory with name bottom_navigation_item.xml and delete left and right padding. |
This is being tracked in the Issue Tracker: https://issuetracker.google.com/115754572 |
public void removePaddingFromNavigationItem() {
I used the global navigation view variable and then just call this method in the oncreate before the setOnNavigationItemSelectedListener |
@sagrawal2418 works like a charm |
Use @sagrawal2418 answer:
in combination with @DhanalakshmiS answer, it works perfectly. There's no padding at all and text remains the same:
|
Thanks, @fk1453, seems like the cleanest solution so far. |
If you are using a theme within the BottomNavigationBar to set font family and text size, then overriding design_bottom_navigation_text_size and design_bottom_navigation_active_text_size won't work. |
Thanks for the Workaround. For those coming to here for the solution, it is working perfectly. |
Thanks, @fatihkizmaz , works like a charm!=) |
app:labelVisibilityMode="unlabeled" |
@kistitan and @sagrawal2418 workaround adapted for kotlin:
|
material-components/material-components-android#139 Signed-off-by: David Sn <divad.nnamtdeis@gmail.com>
This is my approach: Just create a class that extends BottomNavigationView like this: class PaddingLessBottomNavigation(context: Context, attrs: AttributeSet) :
} After that you just have to use your class on you layout like you do on normal BottomNavigationView: <com.your.package.PaddingLessBottomNavigation |
Upgrading to |
Fixed the issue described into this material fix: material-components/material-components-android#139
* WIP: Fixed menu highlights for the main bottom navigation The current fix uses setSelectedItemId to make sure that the correct menu item is selected. This API was introduced in SDK 25.3.0. * Changed the bottom navigation color scheme to see clearly what item is selected * Removed redundant bottom navigation declaration * Fixed active/inactive size + deselected the fist item for activities not mentioned in the bottom navigation bar * Make sure that the Home navigation item is highlighted on activity resume * Made the Comparison activity to redirect to Home like all activities A problem with this was that onOptionItemSelected returned true by default which blocked the call from completing. In our case, we don't have to override the call. Also, the manifest needed to be modified to redirect you to the home activity. * Reworked bottom navigation logic + added compatibility code * Fixed trucated navigation item when the text was to large Fixed the issue described into this material fix: material-components/material-components-android#139
Perfect! |
bottomNavigation Icon by default is showing black-color.How resoved the icon issue in bottomNavigationView android? |
Upgrading to com.google.android.material:material:1.1.0 will fix long text cutting off bug. |
In this theme => Theme.MaterialComponents.Light.NoActionBar.
does not worked for me.
Define these in styles and used in the XML like below.
Hope its helpful to someone. |
@paulshandomain @dimas Mendes its work. thank you |
Reset BottomNavigationItemView long click listener, can resolve long text cutting off in BottomNavigationView. e.g: |
I used this solution with AutoSizing. This works absolutely fine for me.
|
It's fixed now all what you need is to upgrade the version as the following |
Issue still reproducable in implementation 'com.google.android.material:material:1.2.1' |
Having the same issue with '1.3.0-alpha03'. |
It will remove default padding, center align text this will work with old as well new material library.
|
Overview
Long texts cut off in BottomNavigationView only when tab is selected. When tab is unselected, it displays the text properly
When tab is unselected (Meine tickets)
When tab is selected (Meine tickets)
Reproduction steps
Version number
Operating system and device
The text was updated successfully, but these errors were encountered: