Android实现凸起的导航栏 - Go语言中文社区

Android实现凸起的导航栏


国际惯例,首先甩手一张效果图





这个效果在我项目中没有用到,但是看了基友做的一个app有这个效果,感觉挺有趣。

就自己实现了一个玩了,其实起来非常简单,我不像盆友一样自定义一个底部,我是直接写了一个布局


首先了解一个属性

android:clipChildren="false"
这个属性的大概意思:父控件不限制子类的的大小


我的实现方法就一个布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipChildren="false">
    <View
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="#ccc"
    android:layout_above="@+id/ll_bottom"
    />
    <LinearLayout
        android:clipChildren="false"
        android:id="@+id/ll_bottom"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:orientation="horizontal"
        android:layout_alignParentBottom="true"
        android:layout_alignParentStart="true">
        <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_gravity="bottom"
            android:layout_weight="1">
            <ImageView
                android:id="@+id/iv1"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_centerInParent="true"
                android:src="@mipmap/head_one" />

            <TextView
                android:textSize="10sp"
                android:layout_centerInParent="true"
                android:text="文本"
                android:layout_width="wrap_content"
                android:layout_height="18dp"
                android:layout_below="@+id/iv1"/>

        </RelativeLayout>

        <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_gravity="bottom"
            android:layout_weight="1">
            <ImageView
                android:id="@+id/iv2"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_centerInParent="true"
                android:src="@mipmap/head_one" />
            <TextView
                android:textSize="10sp"
                android:layout_centerInParent="true"
                android:text="文本"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/iv2"/>

        </RelativeLayout>

        <RelativeLayout
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_gravity="bottom"
            android:layout_marginBottom="8dp">

            <ImageView
                android:id="@+id/dd5"
                android:layout_width="90dp"
                android:layout_height="70dp"
                android:layout_centerInParent="true"
                android:src="@mipmap/circle" />
            <TextView
                android:textSize="10sp"
                android:layout_centerInParent="true"
                android:text="文本"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/dd5"/>

        </RelativeLayout>

        <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_gravity="bottom"
            android:layout_weight="1">
            <ImageView
                android:id="@+id/iv3"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:src="@mipmap/head_one"
                android:layout_centerVertical="true"
                android:layout_centerHorizontal="true" />
            <TextView
                android:textSize="10sp"
                android:layout_centerInParent="true"
                android:text="文本"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/iv3"/>

        </RelativeLayout>

        <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_gravity="bottom"
            android:layout_weight="1">
            <ImageView
                android:id="@+id/iv4"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_centerInParent="true"
                android:src="@mipmap/head_one" />
            <TextView
                android:textSize="10sp"
                android:layout_centerInParent="true"
                android:text="文本"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/iv4"/>

        </RelativeLayout>

    </LinearLayout>

</RelativeLayout>


代码中用到的两张图片








版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/qq_35270692/article/details/78237587
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2020-04-18 23:16:39
  • 阅读 ( 709 )
  • 分类:

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢