片段的setEnterTransition()和setExitTransition()方法如何工作?

时间:2018-05-25 12:16:26

标签: android android-fragments

  @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment



setEnterTransition(new Slide(Gravity.END));
setExitTransition(new Slide((Gravity.END));
    return inflater.inflate(R.layout.fragment_fragment2, container, false);
}

我在我的片段中尝试了这两种方法来在viewpager中设置动画,但它不起作用。

1 个答案:

答案 0 :(得分:2)

看到它:

 1.setExitTransition() - A’s exit transition animates transitioning views out of the scene when A starts B.

 2.setEnterTransition() - B’s enter transition animates transitioning views into the scene when A starts B.