欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android實(shí)現(xiàn)循環(huán)平移動(dòng)畫示例

 更新時(shí)間:2015年06月09日 11:31:07   投稿:junjie  
這篇文章主要介紹了Android實(shí)現(xiàn)循環(huán)平移動(dòng)畫示例,本文講解實(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ù)。

復(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>

復(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="-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。
復(fù)制代碼 代碼如下:

        <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" />

復(fù)制代碼 代碼如下:

Animation anim = AnimationUtils.loadAnimation(mContext, R.anim.home_animation);
ImageView animationTopRightView = (ImageView)this.findViewById(R.id.animation_top_right);
animationTopRightView.startAnimation(anim);

復(fù)制代碼 代碼如下:

Animation anim2 = AnimationUtils.loadAnimation(mContext, R.anim.home_animation2);
ImageView animationTopLeftView = (ImageView)this.findViewById(R.id.animation_top_left);
animationTopLeftView.startAnimation(anim2);

相關(guān)文章

  • Android仿QQ復(fù)制昵稱效果的實(shí)現(xiàn)方法

    Android仿QQ復(fù)制昵稱效果的實(shí)現(xiàn)方法

    這篇文章主要介紹了Android仿QQ復(fù)制昵稱效果的實(shí)現(xiàn)方法,主要依賴的是一個(gè)開源項(xiàng)目,需要的朋友可以參考下
    2019-05-05
  • Android小程序?qū)崿F(xiàn)選項(xiàng)菜單

    Android小程序?qū)崿F(xiàn)選項(xiàng)菜單

    這篇文章主要為大家詳細(xì)介紹了Android小程序?qū)崿F(xiàn)選項(xiàng)菜單,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-05-05
  • Android AsyncTask源碼分析

    Android AsyncTask源碼分析

    這篇文章主要針對(duì)Android AsyncTask源碼為大家進(jìn)行分析,非常方便的AsyncTask類內(nèi)部封裝了Handler和線程池,感興趣的小伙伴們可以參考一下
    2016-04-04
  • Android處理時(shí)間各種方法匯總

    Android處理時(shí)間各種方法匯總

    這篇文章主要匯總了Android處理時(shí)間的各種方法,如何獲取當(dāng)前時(shí)間,日期之間的比較,如何計(jì)算兩段日期的重合日期等,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-08-08
  • Android入門之Gallery用法實(shí)例解析

    Android入門之Gallery用法實(shí)例解析

    這篇文章主要介紹了Android入門之Gallery用法,對(duì)Android初學(xué)者有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2014-08-08
  • Android實(shí)現(xiàn)橫向二級(jí)菜單

    Android實(shí)現(xiàn)橫向二級(jí)菜單

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)橫向二級(jí)菜單的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-03-03
  • Android實(shí)現(xiàn)設(shè)置APP灰白模式效果

    Android實(shí)現(xiàn)設(shè)置APP灰白模式效果

    大家好,本篇文章主要講的是Android實(shí)現(xiàn)設(shè)置APP灰白模式效果,感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下,方便下次瀏覽
    2021-12-12
  • RollViewPager圖片輪播效果開源框架使用方法詳解

    RollViewPager圖片輪播效果開源框架使用方法詳解

    這篇文章主要為大家詳細(xì)介紹了RollViewPager圖片輪播效果開源框架的使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-10-10
  • kotlin中數(shù)據(jù)類重寫setter getter的正確方法

    kotlin中數(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
  • OpenGL ES著色器使用詳解(二)

    OpenGL ES著色器使用詳解(二)

    這篇文章主要為大家詳細(xì)介紹了OpenGL ES著色器的使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-05-05

最新評(píng)論