Android 中clipToPadding 和 clipChildren區(qū)別和作用
Android 中clipToPadding 和 clipChildren區(qū)別和作用
Android 關(guān)于 clipToPadding 和 clipChildren區(qū)別和作用對(duì)于這兩個(gè)屬性那也是很神奇,
1.對(duì)于clipToPadding 默認(rèn)是true, 這個(gè)屬性一般都是viewgrounp對(duì)象才會(huì)用到, 他的意思就是 對(duì)于padding 所占的尺寸大小也繪制 其他的item的view,
2.對(duì)于clipChildren 默認(rèn)是true,這個(gè)屬性是讓子view不受父view大小的限制,可以超過(guò)父view的寬高,延伸到周?chē)鷙iew內(nèi)部
下面放入效果圖:

第一個(gè)布局是:viewpager 讓兩邊的縮進(jìn)的同時(shí)讓其他的也顯示一部分,這種效果,就會(huì)用到 clipToPadding = false屬性

這個(gè)布局就用到了clipChildren = false,能讓flatbutton從上面布局延伸到周?chē)牟季謨?nèi)部而不被覆蓋,例如下面的布局也是

以上基本都是這兩個(gè)屬性的區(qū)別;例子
<?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>
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
相關(guān)文章
Android設(shè)置桌面背景圖片的實(shí)現(xiàn)方法
有時(shí)候我們需要用android設(shè)置桌面背景圖片,這里簡(jiǎn)單分享下,方便需要的朋友2013-06-06
Android自定義listview布局實(shí)現(xiàn)上拉加載下拉刷新功能
這篇文章主要介紹了Android自定義listview布局實(shí)現(xiàn)上拉加載下拉刷新功能,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-12-12
android實(shí)現(xiàn)可以滑動(dòng)的平滑曲線(xiàn)圖
這篇文章主要為大家詳細(xì)介紹了android實(shí)現(xiàn)可以滑動(dòng)的平滑曲線(xiàn)圖,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-06-06
android書(shū)架效果實(shí)現(xiàn)原理與代碼
以前也模仿者ireader實(shí)現(xiàn)了書(shū)架的效果,但是那種是使用listview實(shí)現(xiàn)的,并不好用,今天介紹android書(shū)架效果實(shí)現(xiàn)方法2013-01-01
android實(shí)現(xiàn)手機(jī)截屏并保存截圖功能
這篇文章主要為大家詳細(xì)介紹了android實(shí)現(xiàn)手機(jī)截屏并保存截圖功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-10-10
Android Lottie實(shí)現(xiàn)中秋月餅變明月動(dòng)畫(huà)特效實(shí)例
Lottie是Airbnb開(kāi)源的一個(gè)支持 Android、iOS 以及 ReactNative,利用json文件的方式快速實(shí)現(xiàn)動(dòng)畫(huà)效果的庫(kù),下面這篇文章主要給大家介紹了關(guān)于A(yíng)ndroid Lottie實(shí)現(xiàn)中秋月餅變明月動(dòng)畫(huà)特效的相關(guān)資料,需要的朋友可以參考下2021-09-09
Ubuntu中為Android增加硬件抽象層(HAL)模塊訪(fǎng)問(wèn)Linux內(nèi)核驅(qū)動(dòng)程序
本文主要介紹在Ubuntu上為Android HAL模塊訪(fǎng)問(wèn)Linux內(nèi)核驅(qū)動(dòng)程序,這里給大家提供方法和一個(gè)小的測(cè)試程序代碼,以及常遇到的問(wèn)題和解決方法,有需要的小伙伴可以參考下2016-08-08
Android編程實(shí)現(xiàn)使用webView打開(kāi)本地html文件的方法
這篇文章主要介紹了Android編程實(shí)現(xiàn)使用webView打開(kāi)本地html文件的方法,結(jié)合實(shí)例形式分析了Android中webview布局及打開(kāi)HTML文件的功能實(shí)現(xiàn)技巧,需要的朋友可以參考下2017-02-02

