简体   繁体   English

底部导航图标高度 Android

[英]BottomNavigation Icon Elevation Android

在此处输入图像描述
I am using in my project a bottom navigation view.我在我的项目中使用底部导航视图。 In the bar bellow i have 4 icons and when selected they become green and get an elevation.在下面的栏中,我有 4 个图标,选择后它们变为绿色并获得高度。 I suspect the color change is coming from the primary color of the app but I want to get rid of the elevation.我怀疑颜色变化来自应用程序的原色,但我想摆脱高程。 I am using a BottomNavigation project so all the code in Activity and XML are the basic ones for a bottom nav.我正在使用一个底部导航项目,因此 Activity 和 XML 中的所有代码都是底部导航的基本代码。

About the position of the selected icon it depends by the label.关于所选图标的 position 取决于 label。
It could be empty and in any case you can use the labelVisibilityMode attribute in your BottomNavigationView :它可能是空的,在任何情况下,您都可以在BottomNavigationView中使用labelVisibilityMode属性:

  <com.google.android.material.bottomnavigation.BottomNavigationView
      app:labelVisibilityMode="unlabeled"
      ..>

With 4 icons the default value is selected : Label is shown on the selected navigation item .使用 4 个图标选择默认值: Label 显示在所选导航项上selected

About the color you can use the itemIconTint attribute.关于颜色,您可以使用itemIconTint属性。 It is the default selector:它是默认选择器:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:alpha="1.0" android:color="?attr/colorPrimary" android:state_checked="true"/>
  <item android:alpha="0.6" android:color="?attr/colorOnSurface"/>
</selector>

You can use a custom selector您可以使用自定义选择器

  <com.google.android.material.bottomnavigation.BottomNavigationView
      app:labelVisibilityMode="unlabeled"
      itemIconTint="@color/my_selector"
      ..>

or just override the default colors in your BottomNavigationView :或者只是覆盖您的 BottomNavigationView 中的默认BottomNavigationView

  <com.google.android.material.bottomnavigation.BottomNavigationView
      app:labelVisibilityMode="unlabeled"
      android:theme="@style/ThemeOverlay.BottomNavView"
      ..>

with:和:

<style name="ThemeOverlay.BottomNavView" parent="">
    <item name="colorPrimary">@color/colorAccent</item>
    <item name="colorOnSurface">@color/primaryDarkColor</item>
</style>

在此处输入图像描述 在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM