你的位置:首页 > 软件开发 > 操作系统 > 浅谈android:clipChildren属性

浅谈android:clipChildren属性

发布时间:2016-08-13 22:00:07
实现功能:1、APP主界面底部模块栏2、ViewPager一屏多个界面显示3、........ 首先需要了解一下这个属性的意思 ,即是否允许子View超出父View的返回,有两个值true 、false ,默认true使用的时候给子View和根节点View控件都设置an ...

浅谈android:clipChildren属性

实现功能:

1、APP主界面底部模块栏

2、ViewPager一屏多个界面显示

3、........

 

首先需要了解一下这个属性的意思 ,即

是否允许子View超出父View的返回,有两个值true 、false  ,默认true

使用的时候给子View和根节点View控件都设置android:clipChildren="false",那么这个子View就不会限制在父View当中

-------------------------------------------------------------------------------------------------------------

下面通过两个项目中经常用到的例子来说明:

1、APP主界面底部模块栏

浅谈android:clipChildren属性

可以看出底部其实有一个ViewGroup(LinearLayout or RelativeLayout 灰色背景部分) 

但是我们要求中间一个图标按钮 是要比别的稍大点的,那么正常的我们写在一个LinearLayout中会出现下面这种情况

浅谈android:clipChildren属性

因为ViewGroup有高度限制,导致他也限制了它内部子View的高度,很显然达不到我们的需求。那么我们需要一种属性来让子View可以不受到父容器的限制

这就要用到了android:clipChildren属性

我们只需要给 根节点控件 和 不想被父容器限制的子View 设置这个属性: android:clipChildren="false"  即可

布局代码:

浅谈android:clipChildren属性浅谈android:clipChildren属性
<LinearLayout "http://schemas.android.com/apk/res/android"  ="http://schemas.android.com/tools" android:layout_width="match_parent"  android:layout_height="match_parent"  android:background="#fff"  android:clipChildren="false"  tools:context="com.xqx.com.treat.ui.user.Login">  <LinearLayout    android:layout_width="match_parent"    android:layout_height="45dp"    android:orientation="horizontal"    android:layout_gravity="bottom"    android:background="#ddd"    >  <ImageView    android:layout_width="0dp"    android:layout_height="match_parent"    android:layout_weight="1"    android:background="#0000"    android:scaleType="fitCenter"    android:src='/images/loading.gif' data-original="@mipmap/ic_launcher"    />  <ImageView    android:layout_width="0dp"    android:layout_height="match_parent"    android:layout_weight="1"    android:background="#0000"    android:scaleType="fitCenter"    android:src='/images/loading.gif' data-original="@mipmap/ic_launcher"    />  <ImageView    android:layout_width="0dp"    android:layout_height="65dp"    android:layout_weight="1"    android:background="#0000"    android:layout_gravity="bottom"    android:scaleType="fitCenter"    android:src='/images/loading.gif' data-original="@mipmap/ic_launcher"    />  <ImageView    android:layout_width="0dp"    android:layout_height="match_parent"    android:layout_weight="1"    android:background="#0000"    android:scaleType="fitCenter"    android:src='/images/loading.gif' data-original="@mipmap/ic_launcher"    />  <ImageView    android:layout_width="0dp"    android:layout_height="match_parent"    android:layout_weight="1"    android:background="#0000"    android:scaleType="fitCenter"    android:src='/images/loading.gif' data-original="@mipmap/ic_launcher"    />    </LinearLayout></LinearLayout>

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:浅谈android:clipChildren属性

关键词:Android

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录