【问题标题】:How to correctly display outlined icon in Android Bottom Navigation View如何在 Android 底部导航视图中正确显示轮廓图标
【发布时间】:2020-06-21 10:03:15
【问题描述】:

我当前的 Android 应用程序使用 com.google.android.material.bottomnavigation.BottomNavigationView

我有四个图标,其中一个是 person outline 的标准 android 矢量图像

如上图

但在应用程序底部导航窗口中,它类似于以下内容:-

导航栏的 xml 布局类似于:-

<com.google.android.material.bottomnavigation.BottomNavigationView
    android:id="@+id/home_bottom_navigation_bar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:itemTextColor="@color/bottom_navigation_bar_color"
    app:itemIconTint="@color/bottom_navigation_bar_color"
    android:layout_alignParentBottom="true"
    android:layout_marginStart="0dp"
    android:layout_marginEnd="0dp"
    android:background="?android:attr/windowBackground"
    app:labelVisibilityMode="unlabeled"
    app:menu="@menu/bottom_nav_menu" />

我做错了什么没有正确显示轮廓图标?

【问题讨论】:

  • 我认为底部导航视图不会填充图标。也许您应该仔细检查以确保您使用的是您打算使用的同一个可绘制对象。
  • @Qunata,好主意,但是我已经仔细检查过,我正在使用图标的轮廓版本。可能底部导航栏没有正确支持矢量图形?
  • 这是因为图标被app:itemIconTint着色。你必须使用bottomNavigationView.setItemIconTintList(null);,但它适用于所有图标。

标签: android android-bottomnavigationview


【解决方案1】:

这对我有用:

bottomNavView.itemIconTintList = null

【讨论】:

    【解决方案2】:

    使用app:itemIconTint="@color/bottom_navigation_bar_color" 可以为图标设置颜色。我认为这可能会解决您的问题。查看文档:https://material.io/develop/android/components/bottom-navigation/

    【讨论】:

    • 如果我错了,请纠正我:图标色调不会影响透明区域。还是这样?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-01
    • 2017-11-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多