概述
android:clipChildren
:字面意思是裁剪子視圖袄琳。用來(lái)定義一個(gè)子視圖的繪制是否可以超出邊界。默認(rèn)值為true,表示不超出邊界,設(shè)置為false時(shí)荔泳,表示允許子視圖超出邊界墨辛。
一布局三張圖了解clipChildren的使用
布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom"
android:clipChildren="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal"
android:background="#FDB300">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@mipmap/ic_launcher"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@mipmap/ic_launcher"/>
<ImageView
android:layout_width="0dp"
android:layout_height="68dp"
android:layout_weight="2"
android:layout_gravity="bottom"
android:src="@mipmap/ic_launcher"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@mipmap/ic_launcher"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@mipmap/ic_launcher"/>
</LinearLayout>
</LinearLayout>
圖一:根布局屬性android:clipChildren="false"
, 中間ImageView的屬性為android:layout_gravity="bottom"
圖二:將根布局屬性android:clipChildren="false"
去掉
圖三:將第三個(gè)ImageView的屬性android:layout_gravity="bottom"
總結(jié)
1躲因、android:clipChildren
必須設(shè)置在根布局
2根暑、中間ImageView設(shè)置屬性android:layout_gravity=bottom
,是從底部向上繪制該子View贮预。