我在FrameLayout中有这个Activity,我用一个共享元素加载两个片段,动画工作,但是很慢而且不流畅。请帮助我使这一转变更加顺利。
public class MainActivity extends FragmentActivity {
Fragment splashFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
splashFragment = new SplashFragment();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.fragmentContainer, splashFragment);
transaction.addToBackStack(null);
transaction.commit();
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
Animate();
}
}, 2000);
}
public void Animate() {
Fragment loginFragment = new LoginFragment();
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
Fade exitFade = new Fade();
exitFade.setDuration(300);
splashFragment.setExitTransition(exitFade);
TransitionSet enterTransitionSet = new TransitionSet();
enterTransitionSet.addTransition(TransitionInflater.from(MainActivity.this).inflateTransition(android.R.transition.move));
enterTransitionSet.setDuration(1000);
enterTransitionSet.setStartDelay(300);
loginFragment.setSharedElementEnterTransition(enterTransitionSet);
Fade enterFade = new Fade();
enterFade.setStartDelay(1300);
enterFade.setDuration(300);
loginFragment.setEnterTransition(enterFade);
View logo = ((SplashFragment) splashFragment).logo;
fragmentTransaction.addSharedElement(logo, logo.getTransitionName());
fragmentTransaction.replace(R.id.fragmentContainer, loginFragment);
fragmentTransaction.commit();
}
}
我在FrameLayout中有这个Activity,我用一个共享元素加载两个片段,动画工作,但是很慢而且不流畅。请帮助我使这一转变更加顺利。
我尝试在清单上使用hardwareacceleration,但没有工作。
我知道应用程序上的所有动画都不是很顺利。