手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >如何让安卓(Android)子控件超出父控件的范围显示
如何让安卓(Android)子控件超出父控件的范围显示
摘要:先来看一张预览图:废话不多说,直接上代码:这张图呢是我刚刚做的,效果是参考了酷狗音乐播放器来完成的,我想说明重点在底部的导航栏:如图再来一张...

先来看一张预览图:

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

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

<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)子控件超出父控件的范围显示2

再来一张反效果预览图:

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

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

android:clipChildren="false"

属性解释和说明:

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

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

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

总结

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

【如何让安卓(Android)子控件超出父控件的范围显示】相关文章:

Android自定义控件之自定义属性

Android中使用sax解析xml文件的方法

Android控件系列之Shape使用方法

Android自定义表格控件满足人们对视觉的需求

Android对字符串的处理

Android监听文件和目录动态

苹果MAC中安装并搭建Android开发环境的详细步骤

Android编程实现图标拖动效果的方法

Android开发:内存机制分析——堆和栈

Android从服务器获取图片的实例方法

精品推荐
分类导航