使用共享元素进行 Android Activity 转换期间的屏幕闪烁问题

问题描述 投票:0回答:1

从初始屏幕转到登录页面时,在 Android 活动转换期间遇到屏幕闪烁,但奇怪的是,从登录页面到注册页面却没有:

有什么办法可以解决这个问题吗?

我见过其他几种解决方案,例如:

下面是我的闪屏Activity活动切换和动画的Java代码:

// on below line we are calling handler to run a task
        // for specific time interval
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent = new Intent(SplashScreen.this, signIn.class);
               // intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);


                // Get the shared element (the View) that will be transitioned between activities
                View sharedElement = findViewById(R.id.logoView);

                // Create the transition animation options
                ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(SplashScreen.this,
                        Pair.create(sharedElement,"shared_logo_transition"));

                // Start the new activity with the transition animation
                startActivity(intent, options.toBundle());


                finish();
                //overridePendingTransition(0, 0);

            }
        }, 1000);
java android performance android-studio mobile-application
1个回答
0
投票
public class SplashScreen extends AppCompatActivity {

    public static Activity activity;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        activity = this;

    }
}



public class signIn extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (SplashScreen.activity != null) {
            finish();
        }

    }

}
© www.soinside.com 2019 - 2024. All rights reserved.