我的BottomNavigationView的选定图标和文本在选定时会移动并变得更大。我在属性中找不到关闭动画的设置。我怎样才能改变这一点?BottomNavigationView使用片段,如下所示:
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomNavigationView"
android:animateLayoutChanges="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000000"
app:itemIconTint="@android:color/tab_indicator_text"
app:itemRippleColor="#00FFFFFF"
app:itemTextColor="#FFFFFF"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/bottom_menu" />
<fragment
android:id="@+id/fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/my_nav"
tools:ignore="FragmentTagUsage" />MainActivity.java如下所示:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Sets the Bottom Navigation
BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavigationView);
NavController navController = Navigation.findNavController(this, R.id.fragment);
NavigationUI.setupWithNavController(bottomNavigationView, navController);
}发布于 2021-03-22 00:24:53
在您的代码中为底部导航视图添加这个“labeled”app:labelVisibilityMode=。它将删除项目水平平移
此外(可选)您可以使用以下代码行修复选定和未选定状态的图标大小: app:itemIconSize="20dp“
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomNavigationView"
android:animateLayoutChanges="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000000"
app:labelVisibilityMode="labeled"
app:itemIconTint="@android:color/tab_indicator_text"
app:itemRippleColor="#00FFFFFF"
app:itemTextColor="#FFFFFF"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/bottom_menu" />https://stackoverflow.com/questions/66734656
复制相似问题