在检查项目时将水平线添加到BottomNavigationView的底部

时间:2019-01-28 05:20:15

标签: android material bottomnavigationview pagerslidingtabstrip

我要在选择时在项目上方显示一个窄条。

我想要类似PagerSlidingTabStripTabs的东西,但是我使用了 BottomNavigationView

1 个答案:

答案 0 :(得分:0)

将bottom属性添加到xml

<android.suport.design.widget.BottomNavigationView
    ...
    app:itemBackground:"@drawable/nav_item_drawable"
    ...
    />

现在在可绘制文件夹中创建“ nav_item_drawable”:

    <selector ....
        <item android:drawable="@drawable/top_of_tab_focused"
              android:state_checked="true" />
    </selector>

然后创建“ top_of_tab_focused”可扩展对象:

<layer-list .....
   <item android:bottom="40dp">
   <shape
      <gradiant
          android:startColor="glass"
          android::centerColor="glass"
          android:endColor="blue" />
      <corners
          android:bottomLeftRadius=90dp"
          android:bottomRightRadius=90dp" />
   </shape>
  </items>
</layer-list>