【Android】神奇的android:clipChildren属性
2016-02-17 16:05
561 查看
【Android】神奇的android:clipChildren属性
前言前几天有在微博上推荐过一个博客,看他文章时发现了这个属性。有些属性不常用,但需要的时候非常有用,于是做了个例子,正好项目用到,与大家分享一下。
声明
欢迎转载,请注明出处!
博客园:http://www.cnblogs.com/
农民伯伯: http://www.cnblogs.com/over140/
正文
一、效果图
看到这个图时你可以先想想如果是你,你怎么实现这个效果。马上想到用RelativeLayout?NO,NO,NO,,,
二、实现代码
<?xml version="1.0" encoding="utf-8"?>
<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" >
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1.0" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dip"
android:background="#B0C4DE"
android:orientation="horizontal" >
<ImageView
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:scaleType="fitCenter"
android:src="@drawable/ic_launcher" />
<ImageView
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:scaleType="fitCenter"
android:src="@drawable/ic_launcher" />
<ImageView
android:layout_width="0dip"
android:layout_height="64dip"
android:layout_gravity="bottom"
android:layout_weight="1.0"
android:scaleType="fitCenter"
android:src="@drawable/ic_launcher" />
<ImageView
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:scaleType="fitCenter"
android:src="@drawable/ic_launcher" />
<ImageView
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:scaleType="fitCenter"
android:src="@drawable/ic_launcher" />
</LinearLayout>
</LinearLayout>
代码说明:
1、只需在根节点设置android:clipChildren为false即可,默认为true
2、可以通过android:layout_gravity控制超出的部分如何显示。
3、android:clipChildren的意思:是否限制子View在其范围内
三、 其他
在做动画的时候非常有用(听说的,,,回头写例子试试看)
相关文章推荐
- GitHub 优秀的 Android 开源项目
- Android 事件分发keyEvent、touchEvent、hoverEvent
- Android如何判断当前手机是否正在播放音乐,并获取到正在播放的音乐的信息
- Android最简洁反编译apk
- android学习笔记---activity延迟跳转实现欢迎界面
- 在Android应用程序使用YouTube API来嵌入视频
- Android--获取当前系统的语言环境
- 安卓开发学习
- R类 和 android.R
- Android应用的R类与资源文件的关系说明
- Android触摸屏事件派发机制详解与源码分析
- Android短信备份案例
- NDK 开发实例
- android 屏幕适配之dp
- Android不同工程中的方法是否可以相互调用
- ANDROID_MARS学习笔记_S01原始版_021_MP3PLAYER001_下载mp3文件
- 命令行开发、编译、打包Android应用程序
- Android TouchEvent事件传递机制
- Android单元测试中insert数据入DB异常
- android 的onCreate 方法