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

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>



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

谷哥的小弟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值