0

I want to use parallax scrolling in fragments in my app. I searched regarding this and i got this link and i did parallax scrolling in images, now i want to do this for fragments.

Earlier I tried to show fragments in viewpager I did that also by using the code that i mentioned below. I tried and searched alot regarding parallax in fragments but I haven't found anything, can anyone help please?

public class Dia3 extends FragmentActivity {

    @Override
    protected void onCreate(Bundle arg0) {
        // TODO Auto-generated method stub
        super.onCreate(arg0);
        setContentView(R.layout.dialog2);

        ViewPager pager = (ViewPager) findViewById(R.id.myfivepanelpager);
        pager.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));
    }

    private class MyPagerAdapter extends FragmentPagerAdapter {

        public MyPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int pos) {
            switch (pos) {

            case 0:
                return Fragment1.newInstance("");

            case 1:
                return Fragment2.newInstance("");
            case 2:
                return Fragment3.newInstance("");
            case 3:
                return Fragment4.newInstance("");
            case 4:
                return Fragment5.newInstance("");
            default:
                return Fragment1.newInstance("");
            }
        }

        @Override
        public int getCount() {
            return 5;
        }
    }
}
abhi
  • 154
  • 16

1 Answers1

1

Check out this library by chrisjenx, also nirhart and this. It should help

EDIT1:

Check this demo also refer this question and this question.

EDIT2:

Check out this library link it is for FRAGMENTS

Community
  • 1
  • 1
Akshay Mukadam
  • 2,388
  • 1
  • 27
  • 40