這是我的 Lottie 影片代碼:
公共類 Splash 擴展了 AppCompatActivity {
ImageView logo,splashImg;
LottieAnimationView lottieAnimationView;
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_splash);
logo = findViewById(R.id.logo);
splashImg = findViewById(R.id.img);
textView = findViewById(R.id.Motto);
lottieAnimationView = findViewById(R.id.lottie);
splashImg.animate().translationY(-2800).setDuration(1000).setStartDelay(4000);
logo.animate().translationY(1850).setDuration(1000).setStartDelay(4000);
textView.animate().translationY(1800).setDuration(1000).setStartDelay(4000);
lottieAnimationView.animate().translationY(1800).setDuration(1000).setStartDelay(4000);
}
}
現在我想去另一個活動,我該怎么做??
uj5u.com熱心網友回復:
您可以Handler為此目的使用該類,然后Activity使用Intent類似方法導航到您的第二個或新的子類。簡而言之,此代碼將通過等待 2000 毫秒或 2 秒(可以自定義)導航到其他活動。也許您可以通過選擇最大的持續時間來根據影片完成時間添加設定
new Handler().postDelayed(new Runnable(){
@Override
private void run(){
Intent intent = new Intent(Splash.this, YourNewActivity.class)
startActivity(intent)
}
}, 2000)
另一種干凈的方法是添加一個AnimationListener,一旦影片完成就Intent啟動另一個Activity
你可以在這里找到AnimationListener專門的使用方法Lottie
uj5u.com熱心網友回復:
請檢查此代碼:
mAddedToCartAnimation.addAnimatorListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
Log.e("Animation:","start");
}
@Override
public void onAnimationEnd(Animator animation) {
startActivity(new Intent(this,NewActivity.class));
//Your code for remove the fragment
try {
getActivity().getSupportFragmentManager()
.beginTransaction().remove(this).commit();
} catch(Exception ex) {
ex.toString();
}
}
@Override
public void onAnimationCancel(Animator animation) {
Log.e("Animation:","cancel");
}
@Override
public void onAnimationRepeat(Animator animation) {
Log.e("Animation:","repeat");
}
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/311112.html
上一篇:找不到符號(Java)
下一篇:unity學習筆記(持續更新)
