-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
[BottomNavigationView] Font changing to bold when selected #3293
Comments
Did you find an workaround solution? |
same problem |
same within our projects. we cannot update beyond 1.7.0 |
same problem here |
+1 |
Workaround if you can't avoid updating the library: extend the import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.widget.TextView
import com.google.android.material.bottomnavigation.BottomNavigationItemView
import com.google.android.material.bottomnavigation.BottomNavigationMenuView
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.navigation.NavigationBarItemView
import com.google.android.material.navigation.NavigationBarMenuView
class NoBoldBottomNavigationView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null
) : BottomNavigationView(context, attrs) {
@SuppressLint("RestrictedApi")
override fun createNavigationBarMenuView(context: Context): NavigationBarMenuView {
return object : BottomNavigationMenuView(context) {
override fun createNavigationBarItemView(context: Context): NavigationBarItemView {
return object : BottomNavigationItemView(context) {
override fun setTextAppearanceActive(activeTextAppearance: Int) {
val largeLabel: TextView? =
findViewById(com.google.android.material.R.id.navigation_bar_item_large_label_view)
val defaultLargeLabelTypeface = largeLabel?.typeface
super.setTextAppearanceActive(activeTextAppearance)
if (defaultLargeLabelTypeface != null) {
largeLabel.typeface = defaultLargeLabelTypeface
}
}
}
}
}
}
} |
@Radiokot We're working on adding a new attr for controlling the boldness separately, it should be available soon, sorry for the inconvenience and thanks for the workaround. |
You can try this. app:itemTextAppearanceActiveBoldEnabled |
This works. Thanks a lot. |
Description: Until the 1.8 Release the NavigationBarItemView was styleable with the attributes itemTextAppearanceActive and itemTextAppearanceInactive (or textAppearanceTitleSmall depending from which theme we are inheriting). Since the release there is a hardcoded line which makes the font bold when selected:
11e98f2
Expected behavior: The user of the library can still decide if the font should be bold when selected. Looking at the TODO one live above it seems like it should be styleable with Tokens. Unfortunately, the design documentation for Material3 does not force selected items to be bold and it does not mention how to style the font of an active/inactive item.
Does an item have to be in bold font when selected?
How can we change the font weight in this case without Material 3 or with Material3?
Source code: 11e98f2
Material Library version: Material Android Library version you are using here (1.8.0 and 1.9.0-alpha2)
The text was updated successfully, but these errors were encountered: