0
I'm與 「android.support.v4.Fragment」 的,做這樣的動畫I'm工作...如何注意popBackStack完成後的片段動畫?
FragmentManager fm = getSupportFragmentManager();
fm.popBackStack();
FragmentTransaction ft = fm.beginTransaction();
ft.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_right, R.anim.slide_in_left, R.anim.slide_out_right);
ImageView ivStart = (ImageView) findViewById(R.id.ivStart);
ivStart.setColorFilter(Color.rgb(80, 80, 80), android.graphics.PorterDuff.Mode.MULTIPLY);
ll_content_frame.setVisibility(View.INVISIBLE);
String itemName = "";
if (position <= (dataList.size() - 1))
itemName = (dataList.get(position)).getItemName();
if (itemName.equalsIgnoreCase(PResText.getString("Inputs_Outputs"))) {
DigIO digIO = new DigIO();
ft.replace(R.id.content_frame, digIO, DigIO.TAG);
ft.addToBackStack(DigIO.TAG);
ft.commit();
fm.executePendingTransactions();
}
.
.
XML這樣的...
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="500"
android:fromXDelta="-100%"
android:toXDelta="0%"
>
</translate>
現在我正試圖注意監聽器或其他什麼東西,當fade_out動畫,由popBackStack()onBackPressed()內開始,正在完成。
我試過這段代碼...通過從這些類中擴展我的片段。
public class MyFragment extends android.support.v4.app.Fragment {
private static final String TAG = "MyFragment";
@Override
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
Animation anim = AnimationUtils.loadAnimation(getActivity(), nextAnim);
anim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
Log.d(TAG, "Animation started.");
// additional functionality
}
@Override
public void onAnimationRepeat(Animation animation) {
Log.d(TAG, "Animation repeating.");
// additional functionality
}
@Override
public void onAnimationEnd(Animation animation) {
Log.d(TAG, "Animation ended.");
// additional functionality
}
});
return anim;
}
}
但這個偵聽器只響應fade_in動畫。
親切的問候原始
...並通知適當的監聽者,例如通過Activity實現。 – 3mpty