Có nhiều lựa chọn làm hình ảnh động giữa các quan điểm một số là người cơ bản như alpha, quy mô, dịch và cũng xoay có new này được giới thiệu trong khái niệm thiết kế tài liệu để xem hiệu ứng chuyển tiếp
đây bạn có thể tìm thấy mẫu mã các tài liệu tham khảo thiết kế git để xem phim hoạt hình https://github.com/lgvalle/Material-Animations
bạn cũng có thể áp dụng oth er hoạt hình sử dụng tài nguyên anim
đây là mã hoạt động bạn phải viết
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splashscreen);
new Handler().postDelayed(new Runnable() {
public void run() {
/* Create an intent that will start the main activity. */
Intent mainIntent = new Intent(SplashScreen.this,
ConnectedActivity.class);
mainIntent.putExtra("id", "1");
//SplashScreen.this.startActivity(mainIntent);
startActivity(mainIntent);
/* Finish splash activity so user cant go back to it. */
SplashScreen.this.finish();
/* Apply our splash exit (fade out) and main
entry (fade in) animation transitions. */
overridePendingTransition(R.anim.mainfadein,R.anim.splashfadeout);
}
}, SPLASH_DISPLAY_TIME);
}
Thêm hai tập tin này trong res/thư mục anim.
slide_in.xml
<?xml version="1.0" encoding="utf-8"?>
<translate
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="100%p"
android:toXDelta="0%p">
</translate>
slide_out.xml
<?xml version="1.0" encoding="utf-8"?>
<translate
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="0%p"
android:toXDelta="-100%p">
</translate>
Tôi hy vọng điều này sẽ được giải quyết thắc mắc của bạn