Android 如何将字幕动画添加到底部导航视图上的图标标题?
我想知道是否有一种方法可以使底部导航栏图标标题像字幕一样滚动。我看过一些类似的应用程序,并试图找到一些方法,但找不到任何方法。因此,如果有人能帮助我,我将不胜感激。有最简单的解决方案。适用于材料组件版本1.0.0-1.2.0-alpha02Android 如何将字幕动画添加到底部导航视图上的图标标题?,android,bottomnavigationview,Android,Bottomnavigationview,我想知道是否有一种方法可以使底部导航栏图标标题像字幕一样滚动。我看过一些类似的应用程序,并试图找到一些方法,但找不到任何方法。因此,如果有人能帮助我,我将不胜感激。有最简单的解决方案。适用于材料组件版本1.0.0-1.2.0-alpha02 fun BottomNavigationView.findAllLabels(): Sequence<TextView> { return sequence { children.forEach { bottomNavig
fun BottomNavigationView.findAllLabels(): Sequence<TextView> {
return sequence {
children.forEach { bottomNavigationChild ->
if (bottomNavigationChild is ViewGroup) {
bottomNavigationChild.children.forEach {
val smallLabel = it.findViewById<TextView>(
com.google.android.material.R.id.smallLabel
)
yield(smallLabel)
val largeLabel = it.findViewById<TextView>(
com.google.android.material.R.id.largeLabel
)
yield(largeLabel)
}
}
}
}
}
// Your BottomNavigationView
bottomNavigationView.findAllLabels().forEach {
it.apply {
ellipsize = TextUtils.TruncateAt.MARQUEE
setSingleLine(true)
// For infinite loop, comment if it's not required
marqueeRepeatLimit = -1
}
}
fun BottomNavigationView.findAllLabels():序列{
返回序列{
children.forEach{bottomNavigationChild->
如果(bottomNavigationChild是视图组){
bottomNavigationChild.children.forEach{
val smallLabel=it.findviewbyd(
com.google.android.material.R.id.smallLabel
)
产量(小标签)
val largeLabel=it.findviewbyd(
com.google.android.material.R.id.largeLabel
)
产量(拉格拉贝尔)
}
}
}
}
}
//您的底部导航视图
bottomNavigationView.FindAllabels().forEach{
申请{
ellipsize=TextUtils.TruncateAt.MARQUEE
设置单行(真)
//对于无限循环,如果不需要,请进行注释
MarqueRepeatLimit=-1
}
}