a亚洲精品_精品国产91乱码一区二区三区_亚洲精品在线免费观看视频_欧美日韩亚洲国产综合_久久久久久久久久久成人_在线区

首頁 > 系統 > Android > 正文

Android實現循環平移動畫示例

2020-04-11 11:30:04
字體:
來源:轉載
供稿:網友

實現用一張背景圖做循環從左往右平移動畫。

1、實現兩個animation xml文件,一個起始位置在-100%p ,一個在0%p。設置repeat屬性為循環,重復。

復制代碼 代碼如下:

<?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里面放兩個一樣的view做背景,view的動畫分別對應上面那兩個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);

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 亚洲视频一区二区三区 | 精品日本一区二区 | 操皮视频 | 最新国产视频 | 亚洲狠狠爱一区二区三区 | 在线免费色 | 女人第一次久久久www | 成人黄视频在线观看 | 亚洲一区免费视频 | 在线一区观看 | 久久成人精品 | 日本黄色片免费 | 精品一区免费 | 亚洲一区二区在线视频 | 精品成人一区 | 午夜影院黄色 | 成人aaa | 曰韩精品一区二区 | 精品一区二区三区三区 | 午夜精品久久久久久99热软件 | 国产精品991 | 亚洲精品在线网站 | 久久久国产一区二区三区四区小说 | 日韩欧美在线免费观看 | 国产成人午夜精品影院游乐网 | 国产日产精品一区二区三区四区 | 在线污污 | 久久一二三区 | 亚洲国产精品99 | 91精品综合久久久久久五月天 | 欧美第8页| 久久99精品久久久久久久青青日本 | 一级免费毛片 | 久久久久国产一区二区三区小说 | 青青青草视频在线 | 国产噜噜噜噜噜久久久久久久久 | 久久三区 | 狠狠插狠狠操 | 日本久久久 | 一级性视频 | 国产区在线观看 |