我创建了一个使用导航抽屉的应用程序,并在其中添加了几个片段(称为:Audi / BMW / Kia /...etc)。现在我想要为抽屉面板和碎片。 我在一个应用程序上看到了一个很酷的过渡,新的活动将抽屉推回到左边。想知道.xml文件在这种动画中的外观如何?
MainActivity.java中的一段
private void displayView(int position) {
// update the main content by replacing fragments
Fragment fragment = null;
switch (position) {
case 0:
fragment = new HomeFragment();
break;
case 1:
fragment = new Audi();
break;
case 2:
fragment = new BMW();
break;
case 3:
fragment = new Volkswagen();
break;
case 4:
fragment = new Kia();
break;
case 5:
fragment = new Volvo();
break;
default:
break;
}
if (fragment != null) {
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.setCustomAnimations(R.animator.fade_in, R.animator.fade_in);
ft.replace(R.id.frame_container, fragment).commit();
// update selected item and title, then close the drawer
mDrawerList.setItemChecked(position, true);
mDrawerList.setSelection(position);
setTitle(navMenuTitles[position]);
mDrawerLayout.closeDrawer(mDrawerList);
} else {
// error in creating fragment
Log.e("MainActivity", "Error in creating fragment");
}
}
fade_in.xml
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:interpolator/accelerate_quad"
android:valueFrom="0"
android:valueTo="1"
android:propertyName="alpha"
android:duration="@android:integer/config_mediumAnimTime" />
我还在寻找&#34;推送&#34;在我的案例中有效的动画......