Android设置android:clipChildren达到的特殊UI设计效果

在Android的布局XML文件中,有一个不常用的属性android:clipChildren,该属性值可设为true或者false。
该属性控制Android的一个子view是否运行超越父控件边界放置。Android系统默认赋予该属性值是true,即不允许超越所在父布局的边界。如果设置为false,则表示允许该子view超越父布局的边界。
当把android:clipChildren的属性设置为false后,在Android的UI设计中会产生一些比较有趣的设计效果,比如下面一个在LinearLayout布局中简单水平并排放置的若干ImageView效果,如图:


其实现代码(布局XML)为:

<?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" >    <LinearLayout        android:layout_width="match_parent"        android:layout_height="100dip"        android:background="#e57373" />    <LinearLayout        android:layout_width="match_parent"        android:layout_height="50dip"        android:background="#2196f3"        android:orientation="horizontal" >        <ImageView            android:layout_width="wrap_content"            android:layout_height="match_parent"            android:src="@drawable/ic_launcher" />        <ImageView            android:layout_width="wrap_content"            android:layout_height="50dip"            android:layout_gravity="bottom"            android:src="@drawable/ic_launcher" />        <ImageView            android:layout_width="wrap_content"            android:layout_height="70dip"            android:layout_gravity="bottom"            android:src="@drawable/ic_launcher" />        <ImageView            android:layout_width="wrap_content"            android:layout_height="90dip"            android:layout_gravity="bottom"            android:src="@drawable/ic_launcher" />        <ImageView            android:layout_width="wrap_content"            android:layout_height="110dip"            android:layout_gravity="bottom"            android:src="@drawable/ic_launcher" />        <ImageView            android:layout_width="wrap_content"            android:layout_height="130dip"            android:layout_gravity="bottom"            android:src="@drawable/ic_launcher" />        <ImageView            android:layout_width="wrap_content"            android:layout_height="150dip"            android:layout_gravity="bottom"            android:src="@drawable/ic_launcher" />        <ImageView            android:layout_width="wrap_content"            android:layout_height="170dip"            android:layout_gravity="bottom"            android:src="@drawable/ic_launcher" />    </LinearLayout>    <LinearLayout        android:layout_width="match_parent"        android:layout_height="100dip"        android:background="#4dd0e1" /></LinearLayout>


android:layout_gravity="bottom" , 告知Android系统要从底部向上绘制该子view。

更多相关文章

  1. Android中使用Lambda
  2. activity的xml详解
  3. 笔记 android 代码中设置Android:layout_gravity
  4. Android(安卓)Animation(API Guides翻译)
  5. Android——实现两个控件水平居中
  6. AndroidManifest.xml文件详解
  7. android fitsSystemWindows的使用
  8. Android(安卓)TextView内容过长加省略号
  9. android 设置透明效果

随机推荐

  1. Android中Math常用的方法,包括pow、abs、r
  2. Android(安卓)Studio更新升级方法
  3. android studio编译警告:请使用 -Xlint:de
  4. Android中实现图文并茂的按钮实例代码
  5. Android应用篇 - app 签名与加固原理分析
  6. 无解的--Response with status: 0 for UR
  7. android studio代理设置
  8. Android:百度定位异常Couldn't load locSD
  9. Android(安卓)Activity屏幕旋转方向完全
  10. 深入研究Android事件传递与重绘