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即可,默認為true。
2、可以通過android:layout_gravity控制超出的部分如何顯示。
3、android:clipChildren的意思:是否限制子View在其范圍內(nèi)。
結(jié)束:
以上例子在做Android 動畫的時候非常有用,有需要的朋友可以參考下。
相關(guān)文章
Android快速開發(fā)之定制BaseTemplate
這篇文章主要為大家詳細介紹了Android快速開發(fā)之定制BaseTemplate的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-02-02Android截取視頻幀并轉(zhuǎn)化為Bitmap示例
利用MediaMetadataRetriever按照時間截取視頻并轉(zhuǎn)換為Bitmap存放于SDCard,具體實現(xiàn)如下,感興趣的朋友可以參考下哈2013-06-06Android利用MPAndroidChart繪制曲線圖表的基礎(chǔ)教程
最近在項目中要用到曲線圖,于是在網(wǎng)上找了很多很多,有AChartengine,MPAndroidChart,helloChart等等,我還用過基于html5的jsChart來做過,不過最終還是選擇了MPAndroidChart來做本文介紹了Android利用MPAndroidChart繪制曲線圖表的基礎(chǔ)教程,需要的朋友可以參考下。2018-03-03android使用url connection示例(get和post數(shù)據(jù)獲取返回數(shù)據(jù))
這篇文章主要介紹了android使用URLConnection來get和post數(shù)據(jù)獲取返回的數(shù)據(jù),大家參考使用吧2014-01-01淺談Android應用安全防護和逆向分析之a(chǎn)pk反編譯
我們有時候在某個app上見到某個功能,某個效果蠻不錯的,我們想看看對方的思路怎么走的,這時候,我們就可以通過反編譯來編譯該apk,拿到代碼,進行分析。2021-06-06Android?NDK入門初識(組件結(jié)構(gòu)開發(fā)流程)
這篇文章主要為大家介紹了Android?NDK入門之初識組件結(jié)構(gòu)開發(fā)流程詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-08-08