我需要一些信息,为什么我的动画会使设备滞后。目前的问题出现在三星Galaxy Tab Pro 8.4'中,但在所有设备上都有轻微的滞后,在键盘上写字很重。谢谢您的合作 !!! :)
PS:谢谢Mikael :)。这是一些代码。它复杂的动画,它包含几个非常类似的部分,具有几个视图的组合动画。
代码:
mTriangleButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mLearnMore = (LinearLayout) ((LoginActivity) context)
.findViewById(R.id.learn_more);
if (mAccNameEmail.isShown()) {
// Slider
if (BookshelfApp.isTablet(context)) {
if(getActivity().getResources().getConfiguration().orientation==Configuration.ORIENTATION_LANDSCAPE) {
mDeseretLogo.setVisibility(View.VISIBLE);
mSquigle.setVisibility(View.VISIBLE);
mBorder.setVisibility(View.VISIBLE);
imm.toggleSoftInput(InputMethodManager.RESULT_HIDDEN, 0);
}
view.animate().translationX(0);
view.animate().setDuration(500);
mLearnMore.animate().translationX(0);
mLearnMore.animate().setDuration(500);
mLearnMore.animate().setListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
mLearnMore.setVisibility(View.GONE);
}
@Override
public void onAnimationRepeat(Animator animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animator animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationCancel(Animator animation) {
// TODO Auto-generated method stub
}
});
//XXX
} else if (!BookshelfApp.isTablet(context)) {
mCreateAccFragment.animate().translationY(0);
mDeseretLogo.setVisibility(View.VISIBLE);
mSquigle.setVisibility(View.VISIBLE);
mBorder.setVisibility(View.VISIBLE);
}
mTextHint1.setVisibility(View.VISIBLE);
mTextHint2.setVisibility(View.VISIBLE);
mTriangleButton.animate().rotation(0);
mTriangleButton.animate().setDuration(500);
mAccPasswords.setVisibility(View.GONE);
mAccNameEmail.setVisibility(View.GONE);
mSignUpButton.setBackgroundDrawable(getResources()
.getDrawable(R.drawable.sign_up_shape));
mSignUpButton.setTextColor(getResources().getColor(
R.color.orange));
mLoginFormView.setVisibility(View.VISIBLE);
mSignInButton.setVisibility(View.VISIBLE);
mForgotPasswordView.setVisibility(View.VISIBLE);
mCreateAccountQuestion
.setText(R.string.acc_question_welcome);
mCreateAccountWord.setText(R.string.acc_welcome);
mHaveAccountButton.setVisibility(View.GONE);
} else {
// Slider
if (BookshelfApp.isTablet(context)) {
if(getActivity().getResources().getConfiguration().orientation==Configuration.ORIENTATION_LANDSCAPE) {
mDeseretLogo.setVisibility(View.GONE);
mSquigle.setVisibility(View.GONE);
mBorder.setVisibility(View.GONE);
imm.toggleSoftInput(InputMethodManager.RESULT_SHOWN, 0);
}
view.animate().translationX(-view.getWidth() / 4);
view.animate().setDuration(500);
mLearnMore.animate().translationX(view.getWidth() / 2);
mLearnMore.animate().setDuration(500);
mLearnMore.animate().setListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animator animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animator animation) {
mLearnMore.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationCancel(Animator animation) {
// TODO Auto-generated method stub
}
});
}
//XXX
else if (!BookshelfApp.isTablet(context)) {
mDeseretLogo.setVisibility(View.GONE);
mSquigle.setVisibility(View.GONE);
mBorder.setVisibility(View.GONE);
}
mTextHint1.setVisibility(View.GONE);
mTextHint2.setVisibility(View.GONE);
mLoginFormView.setVisibility(View.GONE);
mSignInButton.setVisibility(View.GONE);
mForgotPasswordView.setVisibility(View.GONE);
mTriangleButton.animate().rotation(180);
mTriangleButton.animate().setDuration(300);
mAccPasswords.setVisibility(View.VISIBLE);
mAccNameEmail.setVisibility(View.VISIBLE);
mSignUpButton.setBackgroundDrawable(getResources()
.getDrawable(R.drawable.sign_in_shape));
mSignUpButton.setTextColor(getResources().getColor(
R.color.white));
mCreateAccountQuestion.setText(R.string.acc_question);
mCreateAccountWord.setText(R.string.acc_done);
mHaveAccountButton.setVisibility(View.VISIBLE);
}
}
});