diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 54cbce4..100ee10 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -16,6 +16,9 @@
+
+
+
diff --git a/app/src/main/java/com/zhy/magicviewpager/sample/CircleViewPagerActivity.java b/app/src/main/java/com/zhy/magicviewpager/sample/CircleViewPagerActivity.java
new file mode 100644
index 0000000..27e02cb
--- /dev/null
+++ b/app/src/main/java/com/zhy/magicviewpager/sample/CircleViewPagerActivity.java
@@ -0,0 +1,169 @@
+package com.zhy.magicviewpager.sample;
+
+import android.os.Bundle;
+import android.support.v4.view.PagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.support.v7.app.AppCompatActivity;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.Toast;
+
+import com.zhy.magicviewpager.transformer.AlphaPageTransformer;
+import com.zhy.magicviewpager.transformer.NonPageTransformer;
+import com.zhy.magicviewpager.transformer.RotateDownPageTransformer;
+import com.zhy.magicviewpager.transformer.RotateUpPageTransformer;
+import com.zhy.magicviewpager.transformer.RotateYTransformer;
+import com.zhy.magicviewpager.transformer.ScaleInTransformer;
+
+public class CircleViewPagerActivity extends AppCompatActivity{
+
+ private ViewPager mViewPager;
+ private PagerAdapter mAdapter;
+
+ int[] imgRes = {R.drawable.a, R.drawable.b, R.drawable.c, R.drawable.d,
+ R.drawable.e, R.drawable.f, R.drawable.g, R.drawable.h, R.drawable.i};
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_circle_viewpager);
+
+ mViewPager = (ViewPager) findViewById(R.id.id_viewpager);
+
+ mViewPager.setPageMargin(40);
+ mViewPager.setAdapter(mAdapter = new PagerAdapter()
+ {
+ @Override
+ public Object instantiateItem(ViewGroup container, int position)
+ {
+ ImageView view = new ImageView(CircleViewPagerActivity.this);
+// ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
+// view.setLayoutParams(lp);
+// view.setText(position + ":" + view);
+ view.setScaleType(ImageView.ScaleType.FIT_XY);
+// view.setBackgroundColor(Color.parseColor("#44ff0000"));
+ final int realPosition = getRealPosition(position);
+ view.setImageResource(imgRes[realPosition]);
+ container.addView(view);
+// view.setAdjustViewBounds(true);
+
+ view.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Toast.makeText(CircleViewPagerActivity.this, "click position= " + realPosition, Toast.LENGTH_SHORT).show();
+ }
+ });
+ return view;
+ }
+
+
+ @Override
+ public int getItemPosition(Object object) {
+ return POSITION_NONE;
+ }
+
+ @Override
+ public void destroyItem(ViewGroup container, int position, Object object)
+ {
+ container.removeView((View) object);
+ }
+
+ @Override
+ public int getCount()
+ {
+ return Integer.MAX_VALUE;
+ }
+
+ @Override
+ public boolean isViewFromObject(View view, Object o)
+ {
+ return view == o;
+ }
+
+ @Override
+ public void startUpdate(ViewGroup container) {
+ super.startUpdate(container);
+ ViewPager viewPager = (ViewPager) container;
+ int position = viewPager.getCurrentItem();
+ if (position == 0) {
+ position = getFirstItemPosition();
+ } else if (position == getCount() - 1) {
+ position = getLastItemPosition();
+ }
+ viewPager.setCurrentItem(position, false);
+
+ }
+
+ private int getRealCount() {
+ return imgRes.length;
+ }
+
+ private int getRealPosition(int position) {
+ return position % getRealCount();
+ }
+
+ private int getFirstItemPosition() {
+ return Integer.MAX_VALUE / getRealCount() / 2 * getRealCount();
+ }
+
+ private int getLastItemPosition() {
+ return Integer.MAX_VALUE / getRealCount() / 2 * getRealCount() - 1;
+ }
+ });
+
+ mViewPager.setPageTransformer(true, new AlphaPageTransformer());
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu)
+ {
+ String[] effects = this.getResources().getStringArray(R.array.magic_effect);
+ for (String effect : effects)
+ menu.add(effect);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item)
+ {
+ String title = item.getTitle().toString();
+ mViewPager.setAdapter(mAdapter);
+
+ if ("RotateDown".equals(title))
+ {
+ mViewPager.setPageTransformer(true, new RotateDownPageTransformer());
+ } else if ("RotateUp".equals(title))
+ {
+ mViewPager.setPageTransformer(true, new RotateUpPageTransformer());
+ } else if ("RotateY".equals(title))
+ {
+ mViewPager.setPageTransformer(true, new RotateYTransformer(45));
+ } else if ("Standard".equals(title))
+ {
+// mViewPager.setClipChildren(false);
+ mViewPager.setPageTransformer(true, NonPageTransformer.INSTANCE);
+ } else if ("Alpha".equals(title))
+ {
+// mViewPager.setClipChildren(false);
+ mViewPager.setPageTransformer(true, new AlphaPageTransformer());
+ } else if ("ScaleIn".equals(title))
+ {
+ mViewPager.setPageTransformer(true, new ScaleInTransformer());
+ } else if ("RotateDown and Alpha".equals(title))
+ {
+ mViewPager.setPageTransformer(true, new RotateDownPageTransformer(new AlphaPageTransformer()));
+ }else if ("RotateDown and Alpha And ScaleIn".equals(title))
+ {
+ mViewPager.setPageTransformer(true, new RotateDownPageTransformer(new AlphaPageTransformer(new ScaleInTransformer())));
+ }
+
+ setTitle(title);
+
+ return true;
+ }
+}
diff --git a/app/src/main/java/com/zhy/magicviewpager/sample/MainActivity.java b/app/src/main/java/com/zhy/magicviewpager/sample/MainActivity.java
index 6d27fc4..d8956f8 100644
--- a/app/src/main/java/com/zhy/magicviewpager/sample/MainActivity.java
+++ b/app/src/main/java/com/zhy/magicviewpager/sample/MainActivity.java
@@ -1,125 +1,26 @@
package com.zhy.magicviewpager.sample;
+import android.content.Intent;
import android.os.Bundle;
-import android.support.v4.view.PagerAdapter;
-import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
-import android.view.Menu;
-import android.view.MenuItem;
import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import com.zhy.magicviewpager.transformer.AlphaPageTransformer;
-import com.zhy.magicviewpager.transformer.NonPageTransformer;
-import com.zhy.magicviewpager.transformer.RotateDownPageTransformer;
-import com.zhy.magicviewpager.transformer.RotateUpPageTransformer;
-import com.zhy.magicviewpager.transformer.RotateYTransformer;
-import com.zhy.magicviewpager.transformer.ScaleInTransformer;
-
-public class MainActivity extends AppCompatActivity
-{
-
- private ViewPager mViewPager;
- private PagerAdapter mAdapter;
-
- int[] imgRes = {R.drawable.a, R.drawable.b, R.drawable.c, R.drawable.d,
- R.drawable.e, R.drawable.f, R.drawable.g, R.drawable.h, R.drawable.i};
+public class MainActivity extends AppCompatActivity {
@Override
- protected void onCreate(Bundle savedInstanceState)
- {
+ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
-
- mViewPager = (ViewPager) findViewById(R.id.id_viewpager);
-
- mViewPager.setPageMargin(40);
- mViewPager.setOffscreenPageLimit(3);
- mViewPager.setAdapter(mAdapter = new PagerAdapter()
- {
- @Override
- public Object instantiateItem(ViewGroup container, int position)
- {
- ImageView view = new ImageView(MainActivity.this);
-// ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
-// view.setLayoutParams(lp);
-// view.setText(position + ":" + view);
- view.setScaleType(ImageView.ScaleType.FIT_XY);
-// view.setBackgroundColor(Color.parseColor("#44ff0000"));
- view.setImageResource(imgRes[position]);
- container.addView(view);
-// view.setAdjustViewBounds(true);
- return view;
- }
-
- @Override
- public void destroyItem(ViewGroup container, int position, Object object)
- {
- container.removeView((View) object);
- }
-
- @Override
- public int getCount()
- {
- return imgRes.length;
- }
-
- @Override
- public boolean isViewFromObject(View view, Object o)
- {
- return view == o;
- }
- });
- mViewPager.setPageTransformer(true, new AlphaPageTransformer());
-
}
- @Override
- public boolean onCreateOptionsMenu(Menu menu)
- {
- String[] effects = this.getResources().getStringArray(R.array.magic_effect);
- for (String effect : effects)
- menu.add(effect);
- return true;
+ public void onStandardViewPager(View view) {
+ Intent intent = new Intent(MainActivity.this, StandardViewPagerActivity.class);
+ startActivity(intent);
}
- @Override
- public boolean onOptionsItemSelected(MenuItem item)
- {
- String title = item.getTitle().toString();
- mViewPager.setAdapter(mAdapter);
-
- if ("RotateDown".equals(title))
- {
- mViewPager.setPageTransformer(true, new RotateDownPageTransformer());
- } else if ("RotateUp".equals(title))
- {
- mViewPager.setPageTransformer(true, new RotateUpPageTransformer());
- } else if ("RotateY".equals(title))
- {
- mViewPager.setPageTransformer(true, new RotateYTransformer(45));
- } else if ("Standard".equals(title))
- {
-// mViewPager.setClipChildren(false);
- mViewPager.setPageTransformer(true, NonPageTransformer.INSTANCE);
- } else if ("Alpha".equals(title))
- {
-// mViewPager.setClipChildren(false);
- mViewPager.setPageTransformer(true, new AlphaPageTransformer());
- } else if ("ScaleIn".equals(title))
- {
- mViewPager.setPageTransformer(true, new ScaleInTransformer());
- } else if ("RotateDown and Alpha".equals(title))
- {
- mViewPager.setPageTransformer(true, new RotateDownPageTransformer(new AlphaPageTransformer()));
- }else if ("RotateDown and Alpha And ScaleIn".equals(title))
- {
- mViewPager.setPageTransformer(true, new RotateDownPageTransformer(new AlphaPageTransformer(new ScaleInTransformer())));
- }
-
- setTitle(title);
-
- return true;
+ public void onCircleViewPager(View view) {
+ Intent intent = new Intent(MainActivity.this, CircleViewPagerActivity.class);
+ startActivity(intent);
}
+
}
diff --git a/app/src/main/java/com/zhy/magicviewpager/sample/StandardViewPagerActivity.java b/app/src/main/java/com/zhy/magicviewpager/sample/StandardViewPagerActivity.java
new file mode 100644
index 0000000..6e16c4c
--- /dev/null
+++ b/app/src/main/java/com/zhy/magicviewpager/sample/StandardViewPagerActivity.java
@@ -0,0 +1,123 @@
+package com.zhy.magicviewpager.sample;
+
+import android.os.Bundle;
+import android.support.v4.view.PagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.support.v7.app.AppCompatActivity;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+
+import com.zhy.magicviewpager.transformer.AlphaPageTransformer;
+import com.zhy.magicviewpager.transformer.NonPageTransformer;
+import com.zhy.magicviewpager.transformer.RotateDownPageTransformer;
+import com.zhy.magicviewpager.transformer.RotateUpPageTransformer;
+import com.zhy.magicviewpager.transformer.RotateYTransformer;
+import com.zhy.magicviewpager.transformer.ScaleInTransformer;
+
+public class StandardViewPagerActivity extends AppCompatActivity{
+ private ViewPager mViewPager;
+ private PagerAdapter mAdapter;
+
+ int[] imgRes = {R.drawable.a, R.drawable.b, R.drawable.c, R.drawable.d,
+ R.drawable.e, R.drawable.f, R.drawable.g, R.drawable.h, R.drawable.i};
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_standard_viewpager);
+
+ mViewPager = (ViewPager) findViewById(R.id.id_viewpager);
+
+ mViewPager.setPageMargin(40);
+ mViewPager.setOffscreenPageLimit(3);
+ mViewPager.setAdapter(mAdapter = new PagerAdapter()
+ {
+ @Override
+ public Object instantiateItem(ViewGroup container, int position)
+ {
+ ImageView view = new ImageView(StandardViewPagerActivity.this);
+// ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
+// view.setLayoutParams(lp);
+// view.setText(position + ":" + view);
+ view.setScaleType(ImageView.ScaleType.FIT_XY);
+// view.setBackgroundColor(Color.parseColor("#44ff0000"));
+ view.setImageResource(imgRes[position]);
+ container.addView(view);
+// view.setAdjustViewBounds(true);
+ return view;
+ }
+
+ @Override
+ public void destroyItem(ViewGroup container, int position, Object object)
+ {
+ container.removeView((View) object);
+ }
+
+ @Override
+ public int getCount()
+ {
+ return imgRes.length;
+ }
+
+ @Override
+ public boolean isViewFromObject(View view, Object o)
+ {
+ return view == o;
+ }
+ });
+ mViewPager.setPageTransformer(true, new AlphaPageTransformer());
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu)
+ {
+ String[] effects = this.getResources().getStringArray(R.array.magic_effect);
+ for (String effect : effects)
+ menu.add(effect);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item)
+ {
+ String title = item.getTitle().toString();
+ mViewPager.setAdapter(mAdapter);
+
+ if ("RotateDown".equals(title))
+ {
+ mViewPager.setPageTransformer(true, new RotateDownPageTransformer());
+ } else if ("RotateUp".equals(title))
+ {
+ mViewPager.setPageTransformer(true, new RotateUpPageTransformer());
+ } else if ("RotateY".equals(title))
+ {
+ mViewPager.setPageTransformer(true, new RotateYTransformer(45));
+ } else if ("Standard".equals(title))
+ {
+// mViewPager.setClipChildren(false);
+ mViewPager.setPageTransformer(true, NonPageTransformer.INSTANCE);
+ } else if ("Alpha".equals(title))
+ {
+// mViewPager.setClipChildren(false);
+ mViewPager.setPageTransformer(true, new AlphaPageTransformer());
+ } else if ("ScaleIn".equals(title))
+ {
+ mViewPager.setPageTransformer(true, new ScaleInTransformer());
+ } else if ("RotateDown and Alpha".equals(title))
+ {
+ mViewPager.setPageTransformer(true, new RotateDownPageTransformer(new AlphaPageTransformer()));
+ }else if ("RotateDown and Alpha And ScaleIn".equals(title))
+ {
+ mViewPager.setPageTransformer(true, new RotateDownPageTransformer(new AlphaPageTransformer(new ScaleInTransformer())));
+ }
+
+ setTitle(title);
+
+ return true;
+ }
+}
diff --git a/app/src/main/res/layout/activity_circle_viewpager.xml b/app/src/main/res/layout/activity_circle_viewpager.xml
new file mode 100644
index 0000000..94dc63f
--- /dev/null
+++ b/app/src/main/res/layout/activity_circle_viewpager.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 7ee27ed..5e1cecd 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -6,24 +6,25 @@
android:layout_height="match_parent"
tools:context=".MainActivity">
-
-
-
+ android:orientation="vertical">
-
+
+
+
+
diff --git a/app/src/main/res/layout/activity_standard_viewpager.xml b/app/src/main/res/layout/activity_standard_viewpager.xml
new file mode 100644
index 0000000..650478f
--- /dev/null
+++ b/app/src/main/res/layout/activity_standard_viewpager.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+