我对Interpolator有些麻烦...... 我试图制作fadeIN / OUT但这个功能不起作用。我设置了延迟1000毫秒,但没有显示淡入淡出效果。你能救我吗?我检查了一些教程,除了布局宽度/高度之外,所有都应该正确设置,不应该用XML表示。当我删除它们时,会显示这些字段是必填字段的消息:(
XMLs:
FADEIN
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="1000"
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
---------------------
FADEOUT
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:interpolator="@android:anim/decelerate_interpolator"
android:duration="1000"
android:fromAlpha="1.0"
android:toAlpha="0.0">
</alpha>
---------
Main Activity
public class WelcomePage extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome_page);
new Handler().postDelayed(new Thread(){
public void run(){
Intent mainMenu = new Intent(WelcomePage.this,mainMenu.class);
WelcomePage.this.startActivity(mainMenu);
WelcomePage.this.finish();
overridePendingTransition(R.layout.fadein,R.layout.fadeout);
}
},GCEngine.GAME_THREAD_DELAY);
}
}
答案 0 :(得分:0)
将此设置为fade_out
:
android:fillAfter="true"
使用此代码:
new Handler().postDelayed(new Thread(){
public void run(){
Intent mainMenu = new Intent(WelcomePage.this,mainMenu.class);
WelcomePage.this.startActivity(mainMenu);
overridePendingTransition(R.layout.fadein,R.layout.fadeout);
WelcomePage.this.finish();
}
},GCEngine.GAME_THREAD_DELAY);