이 튜토리얼을 찾았습니다 http://android-er.blogspot.com/2012/02/animate-fade-infade-out-by-changing.html 페이드 아웃 같은 이미지 어떻게 두 이미지를 사용하도록이 코드를 변경합니까 페이드 아웃 하나의 이미지 페이드 아웃 두 번째 자동으로 ???페이드 인하는 방법 1 이미지 페이드 아웃 두번째 이미지?
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
public class AndroidAnimTranslateActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button buttonFadeOut = (Button)findViewById(R.id.fadeout);
final ImageView image = (ImageView)findViewById(R.id.image);
Animation animationFadeIn = AnimationUtils.loadAnimation(this, R.anim.fadein);
image.startAnimation(animationFadeIn);
animationFadeIn.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
image.startAnimation(animationFadeOut);
}
});
final Animation animationFadeOut = AnimationUtils.loadAnimation(this,
R.anim.fadeout);
buttonFadeOut.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
image.startAnimation(animationFadeOut);
}});
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<Button
android:id="@+id/fadein"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Fade In"/>
<Button
android:id="@+id/fadeout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Fade Out"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/ic_launcher" />
</LinearLayout>
</LinearLayout>
<!-------fadein.xml-->>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<alpha
android:fromAlpha="0.1"
android:toAlpha="1.0"
android:duration="2000"
/>
</set>
<!--------fadeout.xml----->
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.1"
android:duration="2000"
/>
</set>
종료됩니다 동안
그래서 두 번째 애니메이션이 시작됩니다. [여기] [1] 당신은 예제를 찾을 수 있습니다. [1] : http://stackoverflow.com/questions/9987839/android-imageswitcher-example – Aram
선언 최종 애니메이션 animationFadeOut = AnimationUtils.loadAnimation (이, R.anim.fadeout); before image.startAnimation (animationFadeOut); –
그리고 난 buttonFadeIn의 onClick을 호출해야한다고 생각합니다 –