특정 단편 전환 동작에 도달하려고합니다. 오른쪽은에서 시작 지점으로 다시 같은 방향으로 사라집니다 .. 이 내 XML 애니메이션입니다오른쪽에서 왼쪽으로 단편 전환이 나타나고 왼쪽에서 오른쪽으로 사라집니다 (시작 지점으로 돌아 가기)
right_to_left.xml :
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="1000"
android:fromXDelta="100%"
android:fromYDelta="0%"
android:toXDelta="0%"
android:toYDelta="0%" />
left_to_right.xml
조각이 나타나면: 16,
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="1000"
android:fromXDelta="0%"
android:fromYDelta="0%"
android:toXDelta="-100%"
android:toYDelta="0%" />
여기에 내가 단편 애니메이션을 달성하기 위해 노력했습니다 여러 가지 방법이다
productHolder.fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle bundle = new Bundle();
bundle.putSerializable(Utils.productDetailsKey, productPojo);
ProductDetailsFragment productDetailsFragment = new ProductDetailsFragment();
productDetailsFragment.setArguments(bundle);
FragmentManager fragmentManager = activity.getSupportFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.setCustomAnimations(R.anim.product_animation_enter, R.anim.product_animation_enter);
transaction.add(R.id.newContainer, productDetailsFragment);
transaction.commit();
MainActivity.transparent.setBackgroundColor(ContextCompat.getColor(context, R.color.blackTransparent));
}
});
조각이 방법 하나를 사라
:fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.setCustomAnimations(R.anim.product_animation_exit, R.anim.product_animation_exit);
transaction.remove(ProductDetailsFragment.this);
transaction.commitAllowingStateLoss();
MainActivity.transparent.setBackgroundColor(0x00000000);
}
});
조각이 방법이 사라지면 : image 가 사전에 감사합니다 사람들의 불행하게도 아무도 내가 예상 한대로 작동하지
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.product_animation_exit);
animation.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime));
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
try {
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.remove(ProductDetailsFragment.this);
transaction.commitAllowingStateLoss();
MainActivity.transparent.setBackgroundColor(0x00000000);
} catch (Exception e) {
}
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
getView().startAnimation(animation);
}
});
, 이 이미지는 내가 원하는 것을 더 설명 할 수있다.