I want to show animations on every content of layout inflater. Below is the code that I am using but the problem is animations shows only on first page of view pager.
What I have understood so far is that animations on all pages content gets loaded on position 0 but I may be wrong.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = null;
if (position == 0) {
Home.rel_footer.setVisibility(View.VISIBLE);
v = inflater.inflate(R.layout.reward_points_circles, container,
false);
YoYo.with(Techniques.ZoomIn).duration(5000)
.playOn(v.findViewById(R.id.circle_1));
YoYo.with(Techniques.ZoomIn).duration(5000)
.playOn(v.findViewById(R.id.circle_2));
YoYo.with(Techniques.ZoomIn).duration(5000)
.playOn(v.findViewById(R.id.circle_3));
} else if (position == 1) {
Home.rel_footer.setVisibility(View.GONE);
v = inflater.inflate(R.layout.qrcode_scanner_promotion, container,
false);
YoYo.with(Techniques.Landing).duration(5000)
.playOn(v.findViewById(R.id.imgView_iphone));
YoYo.with(Techniques.Landing).duration(5000)
.playOn(v.findViewById(R.id.imgView_ipad));
} else if (position == 2) {
Home.rel_footer.setVisibility(View.GONE);
v = inflater.inflate(R.layout.deals_promotion, container, false);
YoYo.with(Techniques.ZoomIn).duration(5000)
.playOn(v.findViewById(R.id.imgView_iphone_left));
YoYo.with(Techniques.ZoomIn).duration(5000)
.playOn(v.findViewById(R.id.imageView_iphone_front));
YoYo.with(Techniques.ZoomIn).duration(5000)
.playOn(v.findViewById(R.id.imgView_iphone_right));
}
return v;
}
In my opinion you should not apply animations in
onCreateView
if you want to see your animation on each page change. You should instead useOnPageChangeListener
interface and apply your animation there once user has changed a pager (switching to another page).A simple code snippet to get you started.