@Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_view_pager_nested, container, false);
            TextView textView = (TextView) rootView.findViewById(R.id.section_label);
            textView.setText(getString(R.string.section_format,
                    getArguments().getInt(ARG_SECTION_NUMBER)));


            ViewPager mViewPager = (ViewPager) rootView.findViewById(R.id.viewpager);


            List<View> mViews = new ArrayList<>();

            mViews.add(inflater.inflate(R.layout.layout_1, null, false));
            mViews.add(inflater.inflate(R.layout.layout_2, null, false));
            mViews.add(inflater.inflate(R.layout.layout_3, null, false));

            MyAdapter mMyAdapter = new MyAdapter(mViews);
            mViewPager.setAdapter(mMyAdapter);

            //
            final SwipeRefreshLayout mSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeRefreshLayout);
            mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
                @Override
                public void onRefresh() {
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            mSwipeRefreshLayout.setRefreshing(false);
                        }
                    }, 1000);
                }
            });


            final ImageView mImageView = rootView.findViewById(R.id.image);
//            mImageView.setPivotX(Tools.getScreenWidth(getContext()));
//            mImageView.setPivotY(Tools.getScreenHeight(getContext()));
            Button mButton = rootView.findViewById(R.id.button);
            mButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (flag) {
                        mImageView.animate().scaleX(1.0f).setDuration(400);
                        mImageView.animate().scaleY(1.0f).setDuration(400);
                    } else {
                        mImageView.animate().scaleX(0.5f).setDuration(400);
                        mImageView.animate().scaleY(0.5f).setDuration(400);
                    }
                    flag = !flag;

                }
            });

            return rootView;
        }
Returns a new instance of this fragment for the given section
number.
app/src/main/java/home/smart/fly/animations/ui/activity/ViewPagerNestedActivity.java