码迷,mamicode.com
首页 > 移动开发 > 详细

android:clipChildren属性的分析——是否剪裁子View

时间:2014-07-22 23:52:17      阅读:472      评论:0      收藏:0      [点我收藏+]

标签:android   blog   http   java   os   width   

MainActivity如下:
package cc.testclipchildren;

import android.os.Bundle;
import android.app.Activity;
/**
 * android:clipChildren属性的分析
 * 该属性默认值为android:clipChildren="true"
 * 单从字面意思理解clipChildren的意思是:裁剪(缩短)孩子
 * 我们将其值设置为false后那么当子控件的高度高于父控件时
 * 也会完全显示,而不会被压缩.
 * 比如在此例中:
 * 父类线性布局高度指定为50dip
 * 但是第二个ImageView的高度设置为了70dip.
 * 但是该图片依然正常地完整显示,不会只显示一部分
 * 在此可以设置 android:clipChildren="true"观察效果
 * 
 * 注意事项:
 * 在布局的根节点设置该属性android:clipChildren
 * 
 * 参考资料:
 * 1 http://www.cnblogs.com/over140/p/3508335.html
 * 2 http://www.chengxuyuans.com/Android/66745.html
 *   Thank you very much
 *
 */
public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
	}


}


main.xml如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipChildren="false"
    >
   
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dip"
        android:layout_centerInParent="true"
        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="70dip"
            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" />
    </LinearLayout>

</RelativeLayout>



android:clipChildren属性的分析——是否剪裁子View,布布扣,bubuko.com

android:clipChildren属性的分析——是否剪裁子View

标签:android   blog   http   java   os   width   

原文地址:http://blog.csdn.net/lfdfhl/article/details/38051725

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!