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

看到這個圖時你可以先想想如果是你,你怎么實(shí)現(xiàn)這個效果。馬上想到用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>
代碼說明:
1、只需在根節(jié)點(diǎn)設(shè)置android:clipChildren為false即可,默認(rèn)為true。
2、可以通過android:layout_gravity控制超出的部分如何顯示。
3、android:clipChildren的意思:是否限制子View在其范圍內(nèi)。
結(jié)束:
以上例子在做Android 動畫的時候非常有用,有需要的朋友可以參考下。
- 詳解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)類似uc和墨跡天氣的左右拖動效果
本文主要介紹下怎樣在android實(shí)現(xiàn)uc和墨跡天氣那樣的左右拖動效果,具體代碼如下,感興趣的朋友可以參考下哈2013-06-06
Android實(shí)現(xiàn)獲取簽名及公鑰的方法
這篇文章主要介紹了Android實(shí)現(xiàn)獲取簽名及公鑰的方法,可實(shí)現(xiàn)Android通過包名獲取相關(guān)簽名及公鑰的功能,具有一定參考借鑒價值,需要的朋友可以參考下2015-10-10
Android 給圖片加上水印的示例代碼(支持logo+文字)
本篇文章主要介紹了Android 給圖片加上水印的示例代碼(支持logo+文字),具有一定的參考價值,有興趣的可以了解一下2017-08-08
Android studio開發(fā)小型對話機(jī)器人app(實(shí)例代碼)
這篇文章主要介紹了Android studio開發(fā)一個小型對話機(jī)器人app,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-04-04
AndroidStudio接入Unity工程并實(shí)現(xiàn)相互跳轉(zhuǎn)的示例代碼
這篇文章主要介紹了AndroidStudio接入Unity工程并實(shí)現(xiàn)相互跳轉(zhuǎn),本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-12-12
Android自定義View之組合控件實(shí)現(xiàn)類似電商app頂部欄
這篇文章主要為大家詳細(xì)介紹了Android自定義View之組合控件,實(shí)現(xiàn)類似電商app頂部欄的相關(guān)資料,具有參考價值,感興趣的小伙伴們可以參考一下2016-05-05
android自定義組件實(shí)現(xiàn)儀表計(jì)數(shù)盤
這篇文章主要為大家詳細(xì)介紹了android自定義組件實(shí)現(xiàn)儀表計(jì)數(shù)盤,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-11-11

