Android clipChildren屬性實(shí)例詳解
前言
前幾天有在微博上推薦過(guò)一個(gè)博客,看他文章時(shí)發(fā)現(xiàn)了這個(gè)屬性。有些屬性不常用,但需要的時(shí)候非常有用,于是做了個(gè)例子,正好項(xiàng)目用到,與大家分享一下。
正文
一、效果圖

看到這個(gè)圖時(shí)你可以先想想如果是你,你怎么實(shí)現(xiàn)這個(gè)效果。馬上想到用RelativeLayout?NO,NO,NO,,,
二、實(shí)現(xiàn)代碼
<?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>
代碼說(shuō)明:
1、只需在根節(jié)點(diǎn)設(shè)置android:clipChildren為false即可,默認(rèn)為true。
2、可以通過(guò)android:layout_gravity控制超出的部分如何顯示。
3、android:clipChildren的意思:是否限制子View在其范圍內(nèi)。
結(jié)束:
以上例子在做Android 動(dòng)畫(huà)的時(shí)候非常有用,有需要的朋友可以參考下。
- 詳解Android跨進(jìn)程IPC通信AIDL機(jī)制原理
- Android IPC機(jī)制Messenger實(shí)例詳解
- Android之使用Bundle進(jìn)行IPC詳解
- Android系統(tǒng)進(jìn)程間通信(IPC)機(jī)制Binder中的Server和Client獲得Service Manager接口之路
- 淺談Service Manager成為Android進(jìn)程間通信(IPC)機(jī)制Binder守護(hù)進(jìn)程之路
- android IPC之binder通信機(jī)制
- Android IPC機(jī)制ACtivity綁定Service通信代碼實(shí)例
相關(guān)文章
在android中實(shí)現(xiàn)類(lèi)似uc和墨跡天氣的左右拖動(dòng)效果
本文主要介紹下怎樣在android實(shí)現(xiàn)uc和墨跡天氣那樣的左右拖動(dòng)效果,具體代碼如下,感興趣的朋友可以參考下哈2013-06-06
Android實(shí)現(xiàn)獲取簽名及公鑰的方法
這篇文章主要介紹了Android實(shí)現(xiàn)獲取簽名及公鑰的方法,可實(shí)現(xiàn)Android通過(guò)包名獲取相關(guān)簽名及公鑰的功能,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-10-10
Android 給圖片加上水印的示例代碼(支持logo+文字)
本篇文章主要介紹了Android 給圖片加上水印的示例代碼(支持logo+文字),具有一定的參考價(jià)值,有興趣的可以了解一下2017-08-08
Andriod開(kāi)發(fā)中引入jar包的正確方式介紹
andriod中如果引入jar包的方式不對(duì)就會(huì)出現(xiàn)一些奇怪的錯(cuò)誤,用了很長(zhǎng)時(shí)間才解決出現(xiàn)的bug,下面與大家分享下正確引入jar包的方式2013-06-06
Android studio開(kāi)發(fā)小型對(duì)話(huà)機(jī)器人app(實(shí)例代碼)
這篇文章主要介紹了Android studio開(kāi)發(fā)一個(gè)小型對(duì)話(huà)機(jī)器人app,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-04-04
AndroidStudio接入U(xiǎn)nity工程并實(shí)現(xiàn)相互跳轉(zhuǎn)的示例代碼
這篇文章主要介紹了AndroidStudio接入U(xiǎn)nity工程并實(shí)現(xiàn)相互跳轉(zhuǎn),本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-12-12
Android自定義View之組合控件實(shí)現(xiàn)類(lèi)似電商app頂部欄
這篇文章主要為大家詳細(xì)介紹了Android自定義View之組合控件,實(shí)現(xiàn)類(lèi)似電商app頂部欄的相關(guān)資料,具有參考價(jià)值,感興趣的小伙伴們可以參考一下2016-05-05
android自定義組件實(shí)現(xiàn)儀表計(jì)數(shù)盤(pán)
這篇文章主要為大家詳細(xì)介紹了android自定義組件實(shí)現(xiàn)儀表計(jì)數(shù)盤(pán),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-11-11

