关于android的有关问题,貌似很简单
关于android的问题,貌似很简单~
代码如下:
Moving.java
package com.moving;
import com.moving.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
public class Moving extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView iv1 = (ImageView)findViewById(R.id.image);
Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(this, R.anim.move);
iv1.startAnimation(hyperspaceJumpAnimation);
ImageView iv2 = (ImageView)findViewById(R.id.image1);
Animation hyperspaceJumpAnimation2 = AnimationUtils.loadAnimation(this, R.anim.move1);
iv2.startAnimation(hyperspaceJumpAnimation2);
}
}
其中,move.xml
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<scale
android:interpolator= "@android:anim/accelerate_decelerate_interpolator"
android:fromXScale="0.0"
android:toXScale="1.4"
android:fromYScale="0.0"
android:toYScale="1.4"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="700"
android:duration="2000"
android:repeatCount="0"
/>
</set>
move1.xml
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<rotate
android:interpolator= "@android:anim/accelerate_decelerate_interpolator"
android:fromDegrees="0"
android:toDegrees="-360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="8000"
/>
</set>
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/my_image"
/>
<ImageView
android:id="@+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/bg"
/>
</LinearLayout>
写了2个简单的显示图片的效果,可是只看到第一个的效果,为何第二个没有看到,是覆盖了?还是根本就没运行呢~
如果我想依次显示图像的效果,我该怎么实现呢?
跪求大家帮忙~
------解决方案--------------------
可以通过控制iv.setVisible(View.VISIBILE)和iv.setVisible(View.INVISIBILE)来试一下
代码如下:
Moving.java
package com.moving;
import com.moving.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
public class Moving extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView iv1 = (ImageView)findViewById(R.id.image);
Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(this, R.anim.move);
iv1.startAnimation(hyperspaceJumpAnimation);
ImageView iv2 = (ImageView)findViewById(R.id.image1);
Animation hyperspaceJumpAnimation2 = AnimationUtils.loadAnimation(this, R.anim.move1);
iv2.startAnimation(hyperspaceJumpAnimation2);
}
}
其中,move.xml
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<scale
android:interpolator= "@android:anim/accelerate_decelerate_interpolator"
android:fromXScale="0.0"
android:toXScale="1.4"
android:fromYScale="0.0"
android:toYScale="1.4"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="700"
android:duration="2000"
android:repeatCount="0"
/>
</set>
move1.xml
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<rotate
android:interpolator= "@android:anim/accelerate_decelerate_interpolator"
android:fromDegrees="0"
android:toDegrees="-360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="8000"
/>
</set>
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/my_image"
/>
<ImageView
android:id="@+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/bg"
/>
</LinearLayout>
写了2个简单的显示图片的效果,可是只看到第一个的效果,为何第二个没有看到,是覆盖了?还是根本就没运行呢~
如果我想依次显示图像的效果,我该怎么实现呢?
跪求大家帮忙~
------解决方案--------------------
可以通过控制iv.setVisible(View.VISIBILE)和iv.setVisible(View.INVISIBILE)来试一下