티스토리 뷰


public void fadeAnimation(final View tv, boolean isfadeOut) {

final Animation animationFade;

tv.setAlpha(0f);

if (isfadeOut) {

animationFade = AnimationUtils.loadAnimation(this,R.drawable.fadeout);

} else {

animationFade = AnimationUtils.loadAnimation(this,R.drawable.fadein);

}

Handler mhandler = new Handler();

mhandler.postDelayed(new Runnable() {

@Override

public void run() {

// TODO Auto-generated method stub

tv.setAlpha(1f);

tv.startAnimation(animationFade);

}

}, 0);

}



  • 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"

      android:toAlpha="1.0"

      android:duration="1000"

      />

</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"

      android:duration="1000"

      />

</set>


신고

'Android' 카테고리의 다른 글

안드로이드 뷰 fadein, fadeout 적용  (0) 2014.08.30
Android Toast.show() 겹치는 문제  (0) 2014.08.23
댓글
댓글쓰기 폼