android 設定透明動畫
首先在res/anin創建檔案
1.
在main activity裡面建立
2.
1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fadein.xml | |
<?xml version="1.0" encoding="utf-8"?> | |
<alpha xmlns:android="http://schemas.android.com/apk/res/android" | |
android:interpolator="@android:anim/decelerate_interpolator" | |
android:fromAlpha="0.0" | |
android:toAlpha="1.0" | |
android:fillAfter="true" | |
android:duration="200"/> | |
fadeout.xml | |
<?xml version="1.0" encoding="utf-8"?> | |
<alpha xmlns:android="http://schemas.android.com/apk/res/android" | |
android:interpolator="@android:anim/decelerate_interpolator" | |
android:fromAlpha="1.0" | |
android:toAlpha="0.0" | |
android:fillAfter="true" | |
android:duration="200"/> |
在main activity裡面建立
2.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void fadeoutXml(){ | |
Animation animation= AnimationUtils.loadAnimation(this, | |
R.anim.alpha_fadeout); | |
imageView.startAnimation(animation); | |
} | |
private void fadeinXml(){ | |
Animation animation= AnimationUtils.loadAnimation(this, | |
R.anim.alpha_fadein); | |
imageView.startAnimation(animation); | |
} |
留言
張貼留言