Android layoutAnimation詳解及應(yīng)用
Android layoutAnimation詳解及應(yīng)用
前言:
最近在玩一個(gè)APP的時(shí)候,發(fā)現(xiàn)剛進(jìn)入他的頁(yè)面,他頁(yè)面的子控件都是從右側(cè)飛過來的,感覺好牛的樣子,就順便模仿了一個(gè)??粗_實(shí)是比死板呆在那舒服多了!

還是感覺很好看!反正我覺得比死板呆在那好看!你們覺得那!
在看咱們模仿的:

差不多,在微調(diào)一下就好了!
上點(diǎn)代碼,其實(shí)很簡(jiǎn)單:
首先新建一個(gè)anim文件夾在里面新建兩個(gè)xml
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="90%" //空間的執(zhí)行間隔
android:animation="@anim/trans" />
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
<translate
android:fromXDelta="100%p" android:toXDelta="0"
android:duration="200" />
<alpha
android:fromAlpha="0" android:toAlpha="1"
android:duration="200"
/>
</set>
只要把這個(gè)動(dòng)畫在布局里面設(shè)置一下就出現(xiàn)這個(gè)效果,碉堡了!
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#e6e6e6"
android:layoutAnimation="@anim/anim"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|left"
android:background="#ffffff"
android:layout_margin="5dip"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|left"
android:background="#ffffff"
android:layout_margin="5dip"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|left"
android:background="#ffffff"
android:layout_margin="5dip"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|left"
android:background="#ffffff"
android:layout_margin="5dip"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|left"
android:background="#ffffff"
android:layout_margin="5dip"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|left"
android:background="#ffffff"
android:layout_margin="5dip"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|left"
android:background="#ffffff"
android:layout_margin="5dip"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
</LinearLayout>
就這么簡(jiǎn)單的幾句話,感覺用戶體驗(yàn)頓時(shí)上升了不少!真是細(xì)節(jié)決定成敗啊!
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
相關(guān)文章
Android實(shí)現(xiàn)文件或文件夾壓縮成.zip格式壓縮包
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)文件或文件夾壓縮成.zip格式壓縮包,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-07-07
Android studio保存logcat日志到本地的操作
這篇文章主要介紹了Android studio保存logcat日志到本地的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-04-04
Android修行手冊(cè)之ConstraintLayout布局使用詳解
這篇文章主要為大家介紹了Android修行手冊(cè)之ConstraintLayout使用示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-09-09
Android識(shí)別預(yù)裝的第三方App方法實(shí)例
這篇文章主要給大家介紹了關(guān)于Android如何識(shí)別預(yù)裝的第三方App的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-01-01
Android 屬性動(dòng)畫原理與DataBinding
這篇文章主要介紹了Android 屬性動(dòng)畫原理與DataBinding的相關(guān)資料,需要的朋友可以參考下2017-04-04
Android WebView的使用方法及與JS 相互調(diào)用
這篇文章主要介紹了Android WebView的使用方法及與JS 相互調(diào)用的相關(guān)資料,WebView 是 Android 中一個(gè)非常實(shí)用的組​件, WebView 可以使得網(wǎng)頁(yè)輕松的內(nèi)嵌到app里,還可以直接跟js相互調(diào)用,需要的朋友可以參考下2017-07-07
Android圖表庫(kù)HelloCharts的實(shí)例詳解
這篇文章主要介紹了Android中的圖標(biāo)庫(kù)HelloCharts的一些簡(jiǎn)單使用實(shí)例,文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)有一定的參考價(jià)值,需要的可以參考一下2022-01-01

