Android fragments 提高android片段动画性能
我有一个带有“创建帐户”按钮的活动。单击该按钮时,它将执行向上滑动动画。这是缓慢和波涛汹涌。我已经在Nexus4模拟器和GalaxyS7 edge上对此进行了测试。我尝试在Android fragments 提高android片段动画性能,android-fragments,animation,Android Fragments,Animation,我有一个带有“创建帐户”按钮的活动。单击该按钮时,它将执行向上滑动动画。这是缓慢和波涛汹涌。我已经在Nexus4模拟器和GalaxyS7 edge上对此进行了测试。我尝试在asynctask中运行它,但是它并没有改善动画效果 有什么方法可以提高动画性能吗 创建帐户按钮onclick方法: public void createAccount(View v) { Log.i("Login", "Create Account button tapped."); new AsyncTa
asynctask
中运行它,但是它并没有改善动画效果
有什么方法可以提高动画性能吗
创建帐户按钮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();
}
原来我的问题不在于动画。动画性能不佳的原因是,我只为所有应用程序的背景提供了一幅图像 因此,图像正在调整大小-这是一个昂贵的过程 我纠正了这个问题,提供了多个背景图像,在mipmap文件夹中为每个dpi调整了大小
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;
}
}