Я пытаюсь добавить анимацию к фрагменту, появляющемуся при нажатии кнопки, снизу.Android: Как скопировать фрагмент?
Фрагмент макета
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:background="@color/wallet_holo_blue_light"
android:layout_gravity="center"
android:text="This is a fragmentt layout"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
Slide up.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_mediumAnimTime">
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_mediumAnimTime"
android:fromYDelta="50.0%p"
android:interpolator="@android:anim/decelerate_interpolator"
android:toYDelta="30" />
</set>
Назвав его здесь:
public void onClick(View view) {
if(view == button){
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
FragmentOnMap hello = new FragmentOnMap();
fragmentTransaction.add(R.id.fragment_container, hello, "HELLO");
fragmentTransaction.setCustomAnimations(R.animator.slide_up,0);
fragmentTransaction.commit();
}
}
Android Fragments and animation показывает, как скользить вверх и вниз, я просто фрагмент анимировать вверх. Отсюда мой вопрос, второй аргумент функции setcustomanimation()
Я попытался использовать fragmentTransaction.setCustomAnimations()
перед фиксацией, но не помог.
Он появляется внизу, но эффект перехода отсутствует. Любое руководство было бы полезно. Спасибо
Возможный дубликат [Android фрагментов и анимации] (http://stackoverflow.com/questions/ 4817900/android-fragments-and-animation) – jakubbialkowski