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

看到這個圖時你可以先想想如果是你,你怎么實現(xiàn)這個效果。馬上想到用RelativeLayout?NO,NO,NO,,,
二、實現(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é)點設(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實例詳解
- 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通信代碼實例
相關(guān)文章
詳解MVP模式在Android開發(fā)中的應(yīng)用
MVP是MVC衍生而來的,很早以前就由某軟公司提出,近年來在Android應(yīng)用開發(fā)中越來越多的被提及,越來越重要了。這篇文章主要介紹了詳解MVP模式在Android開發(fā)中的應(yīng)用,有興趣的可以了解一下。2016-11-11
Android快速開發(fā)之定制BaseTemplate
這篇文章主要為大家詳細(xì)介紹了Android快速開發(fā)之定制BaseTemplate的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-02-02
Android截取視頻幀并轉(zhuǎn)化為Bitmap示例
利用MediaMetadataRetriever按照時間截取視頻并轉(zhuǎn)換為Bitmap存放于SDCard,具體實現(xiàn)如下,感興趣的朋友可以參考下哈2013-06-06
Android利用MPAndroidChart繪制曲線圖表的基礎(chǔ)教程
最近在項目中要用到曲線圖,于是在網(wǎng)上找了很多很多,有AChartengine,MPAndroidChart,helloChart等等,我還用過基于html5的jsChart來做過,不過最終還是選擇了MPAndroidChart來做本文介紹了Android利用MPAndroidChart繪制曲線圖表的基礎(chǔ)教程,需要的朋友可以參考下。2018-03-03
android使用url connection示例(get和post數(shù)據(jù)獲取返回數(shù)據(jù))
這篇文章主要介紹了android使用URLConnection來get和post數(shù)據(jù)獲取返回的數(shù)據(jù),大家參考使用吧2014-01-01
淺談Android應(yīng)用安全防護(hù)和逆向分析之a(chǎn)pk反編譯
我們有時候在某個app上見到某個功能,某個效果蠻不錯的,我們想看看對方的思路怎么走的,這時候,我們就可以通過反編譯來編譯該apk,拿到代碼,進(jìn)行分析。2021-06-06
揭秘雙十一手機(jī)淘寶圖標(biāo)如何被動態(tài)更換
這篇文章主要介紹了每到雙十一十二的時候Android手機(jī)動態(tài)更換手機(jī)圖標(biāo)的方法,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2021-08-08
Android?NDK入門初識(組件結(jié)構(gòu)開發(fā)流程)
這篇文章主要為大家介紹了Android?NDK入門之初識組件結(jié)構(gòu)開發(fā)流程詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-08-08

