Android 中clipToPadding 和 clipChildren區別和作用
Android 關于 clipToPadding 和 clipChildren區別和作用對于這兩個屬性那也是很神奇,
1.對于clipToPadding 默認是true, 這個屬性一般都是viewgrounp對象才會用到, 他的意思就是 對于padding 所占的尺寸大小也繪制 其他的item的view,
2.對于clipChildren 默認是true,這個屬性是讓子view不受父view大小的限制,可以超過父view的寬高,延伸到周圍view內部
下面放入效果圖:

第一個布局是:viewpager 讓兩邊的縮進的同時讓其他的也顯示一部分,這種效果,就會用到 clipToPadding = false屬性

這個布局就用到了clipChildren = false,能讓flatbutton從上面布局延伸到周圍的布局內部而不被覆蓋,例如下面的布局也是

以上基本都是這兩個屬性的區別;例子
<?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" > <android.support.v4.view.ViewPager android:id="@+id/view_pager" android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1.0" /> <LinearLayout android:layout_width="match_parent" android:layout_height="48dip" android:background="#B0C4DE" 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="fill_parent" android:layout_weight="1.0" android:scaleType="fitCenter" android:src="@drawable/ic_launcher" /> <ImageView android:layout_width="0dip" android:layout_height="64dip" 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" /> <ImageView android:layout_width="0dip" android:layout_height="fill_parent" android:layout_weight="1.0" android:scaleType="fitCenter" android:src="@drawable/ic_launcher" /> </LinearLayout></LinearLayout>
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
新聞熱點
疑難解答