你好成员stackoverflow porblem与bottomnavihationview
在我的应用程序中,我使用BottomNavigationView和4项.它使我的应用程序容易和美丽
BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation_view);
bottomNavigationView.inflateMenu(R.menu.menu_bottom_navigation);
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
int id = item.getItemId();
switch (id){
case R.id.action_one:
break;
case R.id.action_two:
FragmentTransaction manger= getSupportFragmentManager().beginTransaction();
pop_web_view pop3 =new pop_web_view();
pop3.show(manger,null);
break;
case R.id.action_three:
break;
case R.id.action_four:
break;
}
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
在activity_main中:
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_anchorGravity="bottom"
android:paddingTop="560dp"
app:itemBackground="@color/colorDivider"
app:itemIconTint="@color/colorPrimaryDark"
app:itemTextColor="@color/colorPrimaryDark"
app:menu="@menu/menu_bottom_navigation" />
Run Code Online (Sandbox Code Playgroud)
在菜单xml中:
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action_one"
android:icon="@android:drawable/ic_secure"
android:title="One"/>
<item
android:id="@+id/action_two"
android:icon="@android:drawable/ic_dialog_info"
android:title="Two"/>
<item
android:id="@+id/action_three"
android:icon="@android:drawable/ic_dialog_email"
android:title="Three"/> …Run Code Online (Sandbox Code Playgroud) 嗨,我在底部导航栏上有 4 个项目,我遇到了“问题”。我已经通过此链接的方式解决了这个问题 - 如何禁用 BottomNavigationView 切换模式?
现在我想知道如何保持图标和标题的大小相同。我的问题是图标和标题在点击时会变大。我的代码与上面的链接相同。
非常感谢您的帮助。如果需要更多信息,我会添加它。
再次单击当前选项卡时如何禁用重新加载片段BottomNavigationView?
换句话说,如何禁用重新选择BottomNavigationView?
PS:我正在使用NavigationUI设置BottomNavigationView
我在 BottomNavigationView 中使用了 5 个项目,但它只显示活动项目的标签文本。它适用于 3 个项目,但不适用于超过 3 个项目。
目前来看
我想要的就是这样:
活动主文件
<android.support.design.widget.BottomNavigationView
android:id="@+id/main_bottom_navigation"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:background="@color/colorPrimary"
app:itemIconTint="@drawable/bottom_nav_colors"
app:itemTextColor="@drawable/bottom_nav_colors"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation"
android:layout_alignParentLeft="true" />
Run Code Online (Sandbox Code Playgroud)
导航.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/bnavigation_allGames"
android:icon="@drawable/football_footer"
android:checkable="true"
android:title="@string/bmenu_text_all_games" />
<item
android:id="@+id/bnavigation_favourites"
android:icon="@drawable/favourite_footer"
android:checkable="true"
android:title="@string/bmenu_text_favourites" />
<item
android:id="@+id/bnavigation_favourites_A"
android:icon="@drawable/favourite_footer"
android:checkable="true"
android:title="My Teams" />
<item
android:id="@+id/bnavigation_favourites_b"
android:icon="@drawable/favourite_footer"
android:checkable="true"
android:title="My Leagues" />
<item
android:id="@+id/bnavigation_fixtures_standings"
android:icon="@drawable/fixtures_footer"
android:checkable="true"
android:title="@string/bmenu_text_fixtures_standings" />
</menu>
Run Code Online (Sandbox Code Playgroud)
我尝试过多种解决方案,例如
bottomNavigationView.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_LABELED)
Run Code Online (Sandbox Code Playgroud)
还有其他一些,但它们不起作用可能是因为我的 minSdkVersion 是 14。