Android實(shí)現(xiàn)循環(huán)平移動(dòng)畫示例
實(shí)現(xiàn)用一張背景圖做循環(huán)從左往右平移動(dòng)畫。
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)畫分別對(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頁面切換動(dòng)畫實(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)閉或開啟移動(dòng)網(wǎng)絡(luò)數(shù)據(jù)
- Android自定義圓形View實(shí)現(xiàn)小球跟隨手指移動(dòng)效果
相關(guān)文章
Android仿QQ復(fù)制昵稱效果的實(shí)現(xiàn)方法
這篇文章主要介紹了Android仿QQ復(fù)制昵稱效果的實(shí)現(xiàn)方法,主要依賴的是一個(gè)開源項(xiàng)目,需要的朋友可以參考下2019-05-05Android小程序?qū)崿F(xiàn)選項(xiàng)菜單
這篇文章主要為大家詳細(xì)介紹了Android小程序?qū)崿F(xiàn)選項(xiàng)菜單,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-05-05Android實(shí)現(xiàn)橫向二級(jí)菜單
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)橫向二級(jí)菜單的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-03-03Android實(shí)現(xiàn)設(shè)置APP灰白模式效果
大家好,本篇文章主要講的是Android實(shí)現(xiàn)設(shè)置APP灰白模式效果,感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下,方便下次瀏覽2021-12-12kotlin中數(shù)據(jù)類重寫setter getter的正確方法
這篇文章主要給大家介紹了關(guān)于kotlin中數(shù)據(jù)類重寫setter getter的正確方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用kotlin具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2018-06-06