最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

復(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)畫(huà)分別對(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)文章

最新評(píng)論

阜康市| 剑河县| 榆树市| 西昌市| 丰镇市| 法库县| 余江县| 渑池县| 眉山市| 青浦区| 宜兴市| 河东区| 潞城市| 卢龙县| 房产| 河北省| 滦平县| 肃宁县| 红原县| 华宁县| 四川省| 正阳县| 杭州市| 沁源县| 隆安县| 安福县| 长治县| 封开县| 密山市| 阿瓦提县| 蓝田县| 武隆县| 天长市| 安庆市| 恭城| 内黄县| 乐亭县| 合肥市| 汉源县| 方山县| 北碚区|