【问题标题】:Need help in android image sliding animation在android图像滑动动画中需要帮助
【发布时间】:2015-05-11 03:57:31
【问题描述】:

我正在做一个与运输相关的应用程序。所以我需要为一辆公共汽车的图像从左到右制作动画(从左边停靠在中心并从中心到右边退出)我想重复这个动画直到我的飞溅屏幕结束。这就像加载另一个活动时红色总线使用的那样。你能帮我写代码吗?

我试过了,但是输出错误

<animation-list
xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true">
<item android:drawable="@drawable/sp1" android:duration="1000"/>
<item android:drawable="@drawable/sp2" android:duration="1000" />
<item android:drawable="@drawable/sp3" android:duration="1000" />
<item android:drawable="@drawable/sp4" android:duration="1000" />

这个在main

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.splash);
    ImageView mMailTab = (ImageView)findViewById(R.id.splash_view);
    mMailTab.setImageBitmap(null);
    mMailTab.setBackgroundResource( R.anim.splash_anim );

    final AnimationDrawable mailAnimation = (AnimationDrawable) mMailTab.getBackground();
    mMailTab.post(new Runnable() {
        @Override
        public void run() {
            if ( mailAnimation != null ) mailAnimation.start();
          }
    });

【问题讨论】:

  • 请向我们展示您尝试过的代码。
  • 你尝试过什么?
  • 我在 anim 文件夹中试过这个 schemas.android.com/apk/res/android" android:oneshot="true">
  • this in main.java getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.splash); ImageView mMailTab = (ImageView)findViewById(R.id.splash_view); mMailTab.setImageBitmap(null); mMailTab.setBackgroundResource(R.anim.splash_anim); final AnimationDrawable mailAnimation = (AnimationDrawable) mMailTab.getBackground(); mMailTab.post(new Runnable() { @Override public void run() { if ( mailAnimation != null ) mailAnimation.start(); } });

标签: android eclipse animation android-studio


【解决方案1】:

这里是代码使用这个...... 首先在类似 res/animation 中创建一个文件夹 然后创建一个xmlmove.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_interpolator" >

    <translate
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="1000"
        android:fromXDelta="-75%p"
        android:toXDelta="75%p" >
    </translate>
    <translate
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="1000"
        android:fromXDelta="-75%p"
        android:startOffset="800"
        android:toXDelta="75%p" >
    </translate>

</set>

然后申请使用这个

Animation animation = AnimationUtils.loadAnimation(
            getApplicationContext(), R.animation.move);
    animation.setDuration(yourTime);
    imageView.startAnimation(animation);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-26
    • 2016-02-13
    • 2016-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多