底部导航实现使子控件超出父控件的限制

底部导航实现使子控件超出父控件的限制

实现的预期效果:
在这里插入图片描述

代码:`<?xml version="1.0" encoding="utf-8"?>

    <android.support.v4.view.ViewPager
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"></android.support.v4.view.ViewPager>

    <RadioGroup
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="#cccccc"
        android:orientation="horizontal">
        <ImageView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:src="@mipmap/ic_launcher"
            />
        <ImageView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:src="@mipmap/ic_launcher"
            />
        <ImageView
            android:layout_width="0dp"
            android:layout_height="100dp"
            android:layout_weight="1"
            android:layout_gravity="bottom"
            android:src="@mipmap/ic_launcher"
            />
        <ImageView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:src="@mipmap/ic_launcher"
            />
        <ImageView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:src="@mipmap/ic_launcher"
            />
    </RadioGroup>

关键代码:
1.在根布局中 加上android:clipChildren=“false” 默认是true,含义是 是否显示子View显示其中
2.需要超出父布局的子View需要使用 android:layout_gravity才能达到效果
android:layout_gravity=“bottom”
android:layout_gravity=“center”
这两种实现的效果不一样,本人没有了解这个属性设值带来效果区别的解释
希望有读者解答 谢谢。

注意有一点: android:clipChildren=“false” 不一定在项目的最根布局就有效果,遇到如下情况:
实现效果:
在这里插入图片描述
实现效果:
在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值