0
我有一个创建帐户按钮的活动。点击该按钮后,它会执行一个向上滑动的动画。这是缓慢和波涛汹涌。我已经在nexus 4模拟器以及Galaxy s7边缘上测试过了。我试过在asynctask
上运行它,但它没有改善动画。改善android片段动画性能
有没有一种方法可以提高动画效果?
创建帐户按钮的onclick方法:
public void createAccount(View v) {
Log.i("Login", "Create Account button tapped.");
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.setCustomAnimations(R.anim.slide_up, 0);
transaction.add(R.id.create_account_frame_layout, new CreateAccountFragment()).commit();
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
}
}.execute();
}
CreateAccountFragment类:
import android.support.v4.app.Fragment;
public class CreateAccountFragment extends Fragment {
public CreateAccountFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.create_account_background, container, false);
return rootView;
}
}