Android實(shí)現(xiàn)循環(huán)平移動(dòng)畫(huà)示例
實(shí)現(xiàn)用一張背景圖做循環(huán)從左往右平移動(dòng)畫(huà)。
1、實(shí)現(xiàn)兩個(gè)animation xml文件,一個(gè)起始位置在-100%p ,一個(gè)在0%p。設(shè)置repeat屬性為循環(huán),重復(fù)。
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
<translate android:fromXDelta="0%p" android:toXDelta="100%p"
android:repeatMode="restart"
android:interpolator="@android:anim/linear_interpolator"
android:repeatCount="infinite"
android:duration="30000" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
<translate android:fromXDelta="-100%p" android:toXDelta="0%p"
android:repeatMode="restart"
android:interpolator="@android:anim/linear_interpolator"
android:repeatCount="infinite"
android:duration="30000" />
</set>
2、在view的layout里面放兩個(gè)一樣的view做背景,view的動(dòng)畫(huà)分別對(duì)應(yīng)上面那兩個(gè)animation。
<ImageView
android:id="@+id/animation_top_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/logo"
android:src="@drawable/home_animation_bg" />
<ImageView
android:id="@+id/animation_top_right" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/logo"
android:src="@drawable/home_animation_bg" />
Animation anim = AnimationUtils.loadAnimation(mContext, R.anim.home_animation);
ImageView animationTopRightView = (ImageView)this.findViewById(R.id.animation_top_right);
animationTopRightView.startAnimation(anim);
Animation anim2 = AnimationUtils.loadAnimation(mContext, R.anim.home_animation2);
ImageView animationTopLeftView = (ImageView)this.findViewById(R.id.animation_top_left);
animationTopLeftView.startAnimation(anim2);
- Android實(shí)現(xiàn)拖動(dòng)小球跟隨手指移動(dòng)效果
- Android實(shí)現(xiàn)移動(dòng)小球和CircularReveal頁(yè)面切換動(dòng)畫(huà)實(shí)例代碼
- Android自定義控件實(shí)現(xiàn)隨手指移動(dòng)的小球
- Android View移動(dòng)的六種方法小結(jié)
- Android中利用matrix 控制圖片的旋轉(zhuǎn)、縮放、移動(dòng)
- js判斷客戶端是iOS還是Android等移動(dòng)終端的方法
- android實(shí)現(xiàn)關(guān)閉或開(kāi)啟移動(dòng)網(wǎng)絡(luò)數(shù)據(jù)
- Android自定義圓形View實(shí)現(xiàn)小球跟隨手指移動(dòng)效果
相關(guān)文章
android利用ContentResolver訪問(wèn)者獲取手機(jī)短信信息
本篇文章主要介紹了android利用ContentResolver訪問(wèn)者獲取手機(jī)短信信息,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。2017-02-02
Android中ACTION_CANCEL的觸發(fā)機(jī)制與滑出子view的情況
這篇文章主要介紹了Android中ACTION_CANCEL的觸發(fā)機(jī)制與滑出子view的情況,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-09-09
android APP登陸頁(yè)面適配的實(shí)現(xiàn)
這篇文章主要介紹了android APP登陸頁(yè)面適配的實(shí)現(xiàn),小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-09-09
Android 異步獲取網(wǎng)絡(luò)圖片并處理導(dǎo)致內(nèi)存溢出問(wèn)題解決方法
Android異步獲取網(wǎng)絡(luò)圖片并處理圖片Out Of Memory內(nèi)存溢出如何解決呢?本文介紹了操作步驟,感興趣的朋友可以了解下或許對(duì)你有所幫助2013-02-02
Android 數(shù)據(jù)存儲(chǔ)之 FileInputStream 工具類及FileInputStream類的使用
這篇文章主要介紹了Android 數(shù)據(jù)存儲(chǔ)之 FileInputStream 工具類及FileInputStream類的使用的相關(guān)資料,需要的朋友可以參考下2015-11-11
Android自定義view實(shí)現(xiàn)輸入框效果
這篇文章主要為大家詳細(xì)介紹了Android自定義view實(shí)現(xiàn)輸入框效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-03-03
Android IPC進(jìn)程間通信詳解最新AndroidStudio的AIDL操作)
這篇文章主要介紹了Android IPC進(jìn)程間通信的相關(guān)資料,需要的朋友可以參考下2016-09-09
Android實(shí)現(xiàn)手勢(shì)滑動(dòng)和簡(jiǎn)單動(dòng)畫(huà)效果
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)手勢(shì)滑動(dòng)和簡(jiǎn)單動(dòng)畫(huà)效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-05-05

