Android 底部导航栏按钮突出

小知识:
Freeline( Android平台上的秒级编译方案) 阿里巴巴出品,类似Instant Run功能;用了下确实比较爽而且免费推荐大家使用,以下为官方详细介绍
使用文档:https://www.freelinebuild.com/docs/
原理说明:https://yq.aliyun.com/articles/59122?spm=5176.100240.searchblog.56.Sqd0hT

底部导航栏按钮突出,先上效果图
这里写图片描述

之前项目做法:RelativeLayout+RadioGroup+ImageView/TextView

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <View
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/radiogroup"
        android:background="@color/yellow" />


    <RadioGroup
        android:id="@+id/radiogroup"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:background="@color/white"
        android:orientation="horizontal">

        <RadioButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:button="@null"
            android:gravity="center"
            android:text="首页" />

        <RadioButton
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1"
            android:button="@null"
            android:gravity="center" />
        <RadioButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:button="@null"
            android:gravity="center"
            android:text="我的" />

    </RadioGroup>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="60dp"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_gravity="center_horizontal"
        android:background="@mipmap/index_investbtn_bg"
        android:button="@null"
        android:gravity="center"
        android:text="发现" />
</RelativeLayout>

现在做法:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    **android:clipChildren="false"**
    android:orientation="vertical">

    <View
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="@color/yellow" />

    <RadioGroup
        android:id="@+id/radiogroup"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="@color/white"
        android:orientation="horizontal">

        <RadioButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:button="@null"
            android:gravity="center"
            android:text="首页" />

        <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="60dp"
            android:layout_gravity="bottom"
            android:layout_weight="1">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_centerHorizontal="true"
                android:background="@mipmap/index_investbtn_bg"
                android:gravity="center"
                android:text="发现" />
        </RelativeLayout>

        <RadioButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:button="@null"
            android:gravity="center"
            android:text="我的" />

    </RadioGroup>

</LinearLayout>

主要是使用了clipChildren属性,设置子控件是否可以超出父控件范围显示,默认true(不可以)、false(可以),此属性一般用在爷爷级控件上效果比较明显,例如上面效果
layout_gravity控制超出的内容在哪块显示

Google对clipChildren属性的原文描述:
这里写图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值