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>