如何让安卓(Android)子控件超出父控件的范围显示

 更新时间:2016年08月04日 17:29:55   投稿:daisy  
下面我们来看一下关于安卓(Android)子控件超出父控件的范围显示出来的方法,希望这篇文章能够帮助到各位安卓(Android)的开发者们,有碰到此问题的朋友可以进来看看哦。

先来看一张预览图:

 

废话不多说,直接上代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:clipChildren="false">
 
 <ImageView
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_marginBottom="60dp"
  android:background="@mipmap/www" />
 
 
 <LinearLayout
  android:id="@+id/ll_bottom"
  android:layout_width="match_parent"
  android:layout_height="60dp"
  android:layout_alignParentBottom="true"
  android:background="#F8549D"
  android:elevation="10dp"
  android:orientation="horizontal">
 
  <RelativeLayout
   android:layout_width="0dp"
   android:layout_height="match_parent"
   android:layout_gravity="bottom"
   android:layout_weight="1">
 
   <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:src="@mipmap/ic_launcher" />
 
  </RelativeLayout>
 
  <RelativeLayout
   android:layout_width="0dp"
   android:layout_height="match_parent"
   android:layout_gravity="bottom"
   android:layout_weight="1">
 
   <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:src="@mipmap/ic_launcher" />
 
  </RelativeLayout>
 
  <RelativeLayout
   android:layout_width="70dp"
   android:layout_height="70dp"
   android:layout_gravity="bottom"
   android:background="@drawable/bottom_bg_shape">
 
   <ImageView
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:layout_centerInParent="true"
    android:src="@mipmap/icon_go" />
 
  </RelativeLayout>
 
 
  <RelativeLayout
   android:layout_width="0dp"
   android:layout_height="match_parent"
   android:layout_gravity="bottom"
   android:layout_weight="1">
 
   <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:src="@mipmap/ic_launcher" />
 
  </RelativeLayout>
 
  <RelativeLayout
   android:layout_width="0dp"
   android:layout_height="match_parent"
   android:layout_gravity="bottom"
   android:layout_weight="1">
 
   <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:src="@mipmap/ic_launcher" />
 
  </RelativeLayout>
 </LinearLayout>
 
</RelativeLayout>
 

这张图呢是我刚刚做的,效果是参考了酷狗音乐播放器来完成的,我想说明重点在底部的导航栏:如图

 

再来一张反效果预览图:

 

如何使得蓝色圆形的播放键的显示越过粉色的范围。当然经过合理的布局是可以达到这样的效果的,但是却有更简单的方法。也就是在根布局的属性中加入一个来自Android自身提供的属性:

android:clipChildren="false"

属性解释和说明:

    1、android:clipChildren的意思:是否限制子View在其范围内

     2、可以通过android:layout_gravity控制超出的部分如何显示。

    3、只需在根节点设置android:clipChildren为false即可,默认为true

总结

以上就是如何让安卓(Android)子控件超出父控件的范围显示出来的全部内容,大家学会了吗?希望本文可以帮助到各位。

相关文章

  • Android 通知栏的使用方法

    Android 通知栏的使用方法

    不同版本通知栏的创建方式不尽相同,当前官方推荐使用 NotificationCompat 相关的API,兼容到Android 4.0,但是部分新功能,比如内嵌回复操作,旧版本是无法支持的。
    2021-05-05
  • Flutter 分页功能表格控件详细解析

    Flutter 分页功能表格控件详细解析

    这篇文章主要介绍了Flutter 分页功能表格控件详细解析,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2020-04-04
  • Android性能图论在启动优化中的应用示例详解

    Android性能图论在启动优化中的应用示例详解

    这篇文章主要为大家介绍了Android性能图论在启动优化中的应用示例详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2022-10-10
  • Android Flutter实现自定义下拉刷新组件

    Android Flutter实现自定义下拉刷新组件

    在Flutter开发中官方提供了多平台的下拉刷新组件供开发者使用。本文将改造一下这些组件,实现自定义的下拉刷新组件,感兴趣的可以了解一下
    2022-08-08
  • android开发框架afinal使用方法小结

    android开发框架afinal使用方法小结

    这篇文章主要为大家详细总结了android开发框架afinal使用方法,注解功能、文件上传下载功能,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2016-11-11
  • Android RadioButton单选框的使用方法

    Android RadioButton单选框的使用方法

    本篇文章小编为大家介绍,Android RadioButton单选框的使用方法。需要的朋友参考下
    2013-04-04
  • android仿直播圆点加载效果

    android仿直播圆点加载效果

    这篇文章主要为大家详细介绍了android仿直播圆点加载效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2018-07-07
  • Android绘制音乐播放器示波器

    Android绘制音乐播放器示波器

    这篇文章主要为大家详细介绍了Android绘制音乐播放器示波器的相关资料,感兴趣的小伙伴们可以参考一下
    2016-07-07
  • kotlin使用建造者模式自定义对话框

    kotlin使用建造者模式自定义对话框

    这篇文章主要为大家详细介绍了kotlin使用建造者模式自定义对话框的相关资料,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2018-07-07
  • ViewPager 与 Fragment相结合实现微信界面实例代码

    ViewPager 与 Fragment相结合实现微信界面实例代码

    这篇文章主要介绍了ViewPager 与 Fragment相结合实现微信界面实例代码的相关资料,需要的朋友可以参考下
    2016-07-07

最新评论