繁体   English   中英

带有片段的底部导航和所选项目顶部的条形图如下图所示

[英]Bottom navigation with fragments and a bar on top of the selected item as following image

此图像显示所选项目上的条形图。 我怎么才能得到它?
在此输入图像描述

一种常见的方法是制作自定义布局

<LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <View
                android:id="@+id/selector"
                android:background="@color/selector_color"
                android:layout_width="match_parent"
                android:layout_height="5dp"
                android:visibility="invisible" />  <!--Mind the case here-->

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_home" />

</LinearLayout>

使用ClickEvents切换selector可见性

它不会因设备而异 我建议你使用ConstraintLayoutmatch_constraint属性和guidelines

准则文件

暂无
暂无

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

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