【问题标题】:Separator between content and bottom navigation view (material) like PlayStore内容和底部导航视图(材质)之间的分隔符,例如 PlayStore
【发布时间】:2019-09-06 07:47:36
【问题描述】:

新的Play商店底部导航栏看起来像this。 如您所见,底部导航栏和主要内容之间有一个分隔符。 我如何实现这个分隔符? 我正在使用材质 BottomNavigationView。

我当前的 XML 如下所示:

<com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/main_tab_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        app:itemBackground="@color/colorPrimary"
        app:itemTextColor="@color/tab_item"
        app:itemIconTint="@color/tab_item"
        app:layout_constraintBottom_toBottomOf="parent"
        app:menu="@menu/bottom_menu" />

【问题讨论】:

  • 请发布一些您尝试过的代码
  • 你在问怎么画线吗?
  • 不,显然我可以使用自定义视图并画一条线,但我认为可能有更简单的方法,也许 Play 商店没有使用材质 BottomNavigationView。
  • 哪个分隔符??
  • 底部导航栏和主要内容框架之间的分隔符。当您单击链接时,您可以在屏幕截图中看到。

标签: android bottomnavigationview material-components-android


【解决方案1】:

我想我发现了 Play Store 是如何做到的。 存在一个名为“分隔器”的材料组件。

我刚刚将它添加为 BottomNavigationView 的子视图,它看起来与 Play 商店中的完全相同。

这是子视图的新代码:

<View
    android:id="@+id/divider"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="?android:attr/listDivider" />

【讨论】:

  • 所以只是画一条线
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-10
  • 2022-01-20
  • 1970-01-01
相关资源
最近更新 更多