【发布时间】:2020-03-13 18:05:34
【问题描述】:
我想创建一个像 YouTube 这样的 BottomNavigationView 屏幕,但我遇到了一个问题,即视图没有像那样显示。
它完美适用于三个底部菜单,但是当我使用三个以上的菜单时,它的标题被隐藏并且菜单被移动。我不明白为什么会发生这种情况,我尝试了很多技巧但不能解决问题。
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?android:attr/windowBackground"
app:menu="@menu/navigation" />
Java 活动:
BottomNavigationView navigation = findViewById(R.id.navigation);
// I had tried this code but not working
// BottomNavigationMenuView menuView = (BottomNavigationMenuView)
// bottomNavigationView.getChildAt(0);
// bottomNavigationView.setAnimation(null);
// for (int i = 0; i < menuView.getChildCount(); i++) {
// BottomNavigationItemView itemView = (BottomNavigationItemView) menuView.getChildAt(i);
// itemView.setShiftingMode(false);
// itemView.setChecked(false);
// }
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
任何人,请建议我如何实现这一目标。
【问题讨论】:
-
嗨@Garg,请阅读:material.io/design/components/bottom-navigation.html。希望对您有所帮助!
-
@SonhnLab 谢谢,伙计...
标签: android bottomnavigationview