ViewPager动画片段内的视图

时间:2018-05-14 08:14:42

标签: android

我希望在ViewPager中附加的片段内为视图(如缩放/缩放视图)设置动画。

mPager = findViewById(R.id.feedsPager);
mAdapter = new FeedAdapter(getSupportFragmentManager());
mPager.setOffscreenPageLimit(1);
mPager.setAdapter(mAdapter);
mPager.setCurrentItem(pagePosition, false);

动画代码:

feedImage.startAnimation(AnimationUtils.loadAnimation(getActivity().getApplicationContext(),
                    R.anim.feed_detail_image_animation));

feed_detail_image_animation.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="false" >
    <scale
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="250"
        android:fromXScale="0"
        android:fromYScale="0"
        android:pivotX="100%"
        android:pivotY="100%"
        android:toXScale="1"
        android:toYScale="1" />
</set>

但问题是ViewPager中第一个打开的片段内的视图上的动画是不平滑的(有时候视图事件不是动画或动画与混蛋)。但是,如果我在视图中设置动画片段内部有一些延迟,那么它的工作正常。

如果有任何机构有任何想法,请提供帮助

0 个答案:

没有答案