├── ._.DS_Store
├── .gitignore
├── CHANGELOG.md
├── README.md
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── parallaxpagersample
├── ._.DS_Store
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── ._.DS_Store
│ └── main
│ ├── ._.DS_Store
│ ├── AndroidManifest.xml
│ ├── java
│ ├── ._.DS_Store
│ └── com
│ │ ├── ._.DS_Store
│ │ └── xgc1986
│ │ └── parallaxpagersample
│ │ ├── DemoParallaxAdapter.java
│ │ ├── DemoParallaxFragment.java
│ │ └── MainActivity.java
│ └── res
│ ├── ._.DS_Store
│ ├── layout
│ ├── demo_activity_parallax.xml
│ └── demo_fragment_parallax.xml
│ ├── mipmap-hdpi
│ ├── bg_kero.jpg
│ ├── bg_niju.jpg
│ ├── bg_nina.jpg
│ ├── bg_yuki.jpg
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ ├── bg_kero.jpg
│ ├── bg_niju.jpg
│ ├── bg_nina.jpg
│ ├── bg_yuki.jpg
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ ├── bg_kero.jpg
│ ├── bg_niju.jpg
│ ├── bg_nina.jpg
│ ├── bg_yuki.jpg
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ ├── bg_kero.jpg
│ ├── bg_niju.jpg
│ ├── bg_nina.jpg
│ ├── bg_yuki.jpg
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── parallaxpagertransformer
├── ._.DS_Store
├── build.gradle
├── gradle.properties
├── pom.xml
├── proguard-rules.txt
├── settings.xml
└── src
│ ├── ._.DS_Store
│ └── main
│ ├── ._.DS_Store
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── xgc1986
│ └── parallaxPagerTransformer
│ └── ParallaxPagerTransformer.java
├── parallaxpagertransformersample
├── ._.DS_Store
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── ._.DS_Store
│ └── main
│ ├── ._.DS_Store
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── xgc1986
│ │ └── parallaxpagertransformersample
│ │ ├── DemoParallaxAdapter.java
│ │ ├── DemoParallaxFragment.java
│ │ └── MainActivity.java
│ └── res
│ ├── ._.DS_Store
│ ├── layout
│ ├── demo_activity_parallax.xml
│ └── demo_fragment_parallax.xml
│ ├── mipmap-hdpi
│ ├── ._ic_launcher.png
│ ├── bg_kero.jpg
│ ├── bg_niju.jpg
│ ├── bg_nina.jpg
│ ├── bg_yuki.jpg
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ ├── bg_kero.jpg
│ ├── bg_niju.jpg
│ ├── bg_nina.jpg
│ ├── bg_yuki.jpg
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ ├── bg_kero.jpg
│ ├── bg_niju.jpg
│ ├── bg_nina.jpg
│ ├── bg_yuki.jpg
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ ├── bg_kero.jpg
│ ├── bg_niju.jpg
│ ├── bg_nina.jpg
│ ├── bg_yuki.jpg
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
└── settings.gradle
/._.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/._.DS_Store
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #Android generated
2 | bin
3 | gen
4 | gen*
5 |
6 | #Eclipse
7 | .project
8 | .classpath
9 | .settings
10 |
11 | #IntelliJ IDEA
12 | .idea
13 | *.iml
14 | *.ipr
15 | *.iws
16 | out
17 |
18 | #Maven
19 | target
20 | release.properties
21 | pom.xml.*
22 |
23 | #Ant
24 | build.xml
25 | local.properties
26 | proguard.cfg
27 |
28 | #Gradle
29 | .gradle
30 | build
31 |
32 | #OSX
33 | .DS_Store
34 |
35 |
36 | !parallaxDemo.apk
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | ### *(2016-04-02)*
4 | * change minSdkVersion to 16
5 | * change targetSdkVersion to 23
6 | * Fix [Issue #4] Add OSS license type in README.
7 | * Fix [Issue #5] NullPointer Exception.
8 | * Fix [Issue #6] android:allowBackup conflict.
9 |
10 | --------------
11 |
12 | ### *(2015-03-14)*
13 | * change minSdkVersion to 10, but it won't have the parallax effect on such version
14 | * Reorganize the android project
15 | * Moved images from drawables to mipmaps.
16 |
17 | --------------
18 |
19 | ### *(2015-02-25)*
20 | * Fix [Issue #3] moved to jcenter repository.
21 | * fixed a bug on the sample version due to a change on android 5
22 | * update the sample version to use jcenter repository
23 |
24 | --------------
25 |
26 | ### *(2014-07-27)*
27 | * Fix [Issue #2] Update README.md to avoid problem in gradle 0.8.+ ("Error:Module version com.xgc1986.ParallaxPagerTransformer:library:0.2-SNAPSHOT depends on libraries but is not a library itself")
28 |
29 | --------------
30 |
31 | ### (0.2-SNAPSHOT) *(2014-06-23)*
32 | * Replace package parallaxpagerlibrary to parallaxpagertransformer
33 | * Added method setSpeed(float) (default = 0.2f). This change the speed of the effect during the transition between two pages
34 | * Deleted hardcoded values on sample
35 | * Updated sample
36 |
37 | --------------
38 |
39 | ### (0.1-SNAPSHOT) *(2014-06-23)*
40 | * [Issue #1] Change project title to ParallaxPagerTransformer (as suggested by tasomaniac)
41 | * Exported to sonatype.org
42 | * Delete some resources from SampleParallaxProjectSample
43 | * SampleParallaxProjectSample is importing the library from sonatype
44 | * Fix some layout issue from SampleParallaxProjectSample
45 |
46 | --------------
47 |
48 | ### *(2014-06-28)*
49 | * Add `void setBorder(int px)`. Sets a current border while de transition between twopages, the border's with is `px`.
50 |
51 | ```java
52 | /** ... **/
53 |
54 | ViewPager Pager = (ViewPager) findViewById(R.id.pager);
55 | ParallaxTransformer parallaxTransformer = new ParallaxTransformer(R.id.parallaxContent);
56 | parallaxTransformer.setBorder(3);
57 | mPager.setPageTransformer(false, parallaxTransformer);
58 | /** ... **/
59 | ```
60 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://android-arsenal.com/details/1/1312)
2 |
3 | # ParallaxPagerTransformer
4 |
5 | A pager transformer for Android with parallax effect
6 |
7 | ## Installation
8 |
9 | in your build.gradle file
10 |
11 | dependencies {
12 | // ...
13 | compile 'com.xgc1986.android:parallaxpagertransformer:1.0.4'
14 | }
15 |
16 | ## Usage
17 |
18 | minSdkVersion 11
19 |
20 | You only have to pass to the ParallaxTransformer the id of the element you want have the parallax effect
21 |
22 | ```java
23 |
24 | //...
25 | import com.xgc1986.parallaxPagerTransformer.ParallaxPagerTransformer;
26 |
27 | public class MainActivity extends Activity {
28 |
29 | ViewPager mPager;
30 | FragmentStatePagerAdapter mAdapter;
31 |
32 | public void onCreate(Bundle savedInstanceState) {
33 | /** ... **/
34 |
35 | mPager = (ViewPager) findViewById(R.id.pager);
36 |
37 | // creating the parallaxTransformer, you only need to pass the id of the View (or ViewGroup) you want to do the parallax effect
38 |
39 | mPager.setPageTransformer(false, new ParallaxPagerTransformer(R.id.parallaxContent));
40 | mAdapter = new FragmentStatePagerAdapter(getSupportFragmentManager());
41 | mAdapter.setPager(mPager);
42 |
43 | /** ... **/
44 | }
45 | }
46 |
47 | ```
48 |
49 | And that's all, you can see in action Here
50 |
51 | ## Other works
52 | Ripple Button
53 |
54 | [](https://android-arsenal.com/details/1/1312)
55 |
56 | License
57 | --------
58 |
59 | Copyright 2015 Javier Gonzalez
60 |
61 | Licensed under the Apache License, Version 2.0 (the "License");
62 | you may not use this file except in compliance with the License.
63 | You may obtain a copy of the License at
64 |
65 | http://www.apache.org/licenses/LICENSE-2.0
66 |
67 | Unless required by applicable law or agreed to in writing, software
68 | distributed under the License is distributed on an "AS IS" BASIS,
69 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
70 | See the License for the specific language governing permissions and
71 | limitations under the License.
72 |
73 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | mavenCentral()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:2.1.0-alpha5'
10 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
11 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/gradle.properties
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/parallaxpagersample/._.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/._.DS_Store
--------------------------------------------------------------------------------
/parallaxpagersample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/parallaxpagersample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 22
5 | buildToolsVersion "22.0.0"
6 |
7 | defaultConfig {
8 | applicationId "com.xgc1986.parallaxpagersample"
9 | minSdkVersion 11
10 | targetSdkVersion 22
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | compile 'com.android.support:appcompat-v7:22.0.0'
25 | compile project(':parallaxpagertransformer')
26 | }
27 |
--------------------------------------------------------------------------------
/parallaxpagersample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/xgc1986/adt-bundle-mac-x86_64-20130522/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/parallaxpagersample/src/._.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/._.DS_Store
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/._.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/._.DS_Store
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/java/._.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/java/._.DS_Store
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/java/com/._.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/java/com/._.DS_Store
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/java/com/xgc1986/parallaxpagersample/DemoParallaxAdapter.java:
--------------------------------------------------------------------------------
1 | package com.xgc1986.parallaxpagersample;
2 |
3 | import android.support.v4.app.Fragment;
4 | import android.support.v4.app.FragmentManager;
5 | import android.support.v4.app.FragmentStatePagerAdapter;
6 | import android.support.v4.view.ViewPager;
7 |
8 | import java.util.ArrayList;
9 |
10 | public class DemoParallaxAdapter extends FragmentStatePagerAdapter {
11 |
12 | private ArrayList mFragments;
13 | private ViewPager mPager;
14 |
15 | public DemoParallaxAdapter(FragmentManager fm) {
16 | super(fm);
17 |
18 | mFragments = new ArrayList<>();
19 | }
20 |
21 | @Override
22 | public Fragment getItem(int i) {
23 | return mFragments.get(i);
24 | }
25 |
26 | @Override
27 | public int getCount() {
28 | return mFragments.size();
29 | }
30 |
31 | public void add(DemoParallaxFragment parallaxFragment) {
32 | parallaxFragment.setAdapter(this);
33 | mFragments.add(parallaxFragment);
34 | notifyDataSetChanged();
35 | mPager.setCurrentItem(getCount() - 1, true);
36 |
37 | }
38 |
39 | public void remove(int i) {
40 | mFragments.remove(i);
41 | notifyDataSetChanged();
42 | }
43 |
44 | public void remove(DemoParallaxFragment parallaxFragment) {
45 | mFragments.remove(parallaxFragment);
46 |
47 | int pos = mPager.getCurrentItem();
48 | notifyDataSetChanged();
49 |
50 | mPager.setAdapter(this);
51 | if (pos >= this.getCount()) {
52 | pos = this.getCount() - 1;
53 | }
54 | mPager.setCurrentItem(pos, true);
55 |
56 | }
57 |
58 | public int getItemPosition(Object object) {
59 | return POSITION_NONE;
60 | }
61 |
62 | public void setPager(ViewPager pager) {
63 | mPager = pager;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/java/com/xgc1986/parallaxpagersample/DemoParallaxFragment.java:
--------------------------------------------------------------------------------
1 | package com.xgc1986.parallaxpagersample;
2 |
3 | import android.graphics.Matrix;
4 | import android.os.Bundle;
5 | import android.support.v4.app.Fragment;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 |
12 | public class DemoParallaxFragment extends Fragment {
13 |
14 | private DemoParallaxAdapter mCatsAdapter;
15 |
16 | @Override
17 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
18 |
19 | super.onCreateView(inflater, container, savedInstanceState);
20 |
21 | View v = inflater.inflate(R.layout.demo_fragment_parallax, container, false);
22 | final ImageView image = (ImageView) v.findViewById(R.id.image);
23 |
24 | image.setImageResource(getArguments().getInt("image"));
25 | image.post(new Runnable() {
26 | @Override
27 | public void run() {
28 | Matrix matrix = new Matrix();
29 | matrix.reset();
30 |
31 | float wv = image.getWidth();
32 | float hv = image.getHeight();
33 |
34 | float wi = image.getDrawable().getIntrinsicWidth();
35 | float hi = image.getDrawable().getIntrinsicHeight();
36 |
37 | float width = wv;
38 | float height = hv;
39 |
40 | if (wi / wv > hi / hv) {
41 | matrix.setScale(hv / hi, hv / hi);
42 | width = wi * hv / hi;
43 | } else {
44 | matrix.setScale(wv / wi, wv / wi);
45 | height= hi * wv / wi;
46 | }
47 |
48 | matrix.preTranslate((wv - width) / 2, (hv - height) / 2);
49 | image.setScaleType(ImageView.ScaleType.MATRIX);
50 | image.setImageMatrix(matrix);
51 | }
52 | });
53 |
54 |
55 | TextView text = (TextView)v.findViewById(R.id.name);
56 | text.setText(getArguments().getString("name"));
57 |
58 | TextView more = (TextView)v.findViewById(R.id.more);
59 |
60 | more.setOnLongClickListener(new View.OnLongClickListener() {
61 | @Override
62 | public boolean onLongClick(View v) {
63 | if (mCatsAdapter != null) {
64 | mCatsAdapter.remove(DemoParallaxFragment.this);
65 | mCatsAdapter.notifyDataSetChanged();
66 | }
67 | return true;
68 | }
69 | });
70 |
71 | more.setOnClickListener(new View.OnClickListener() {
72 | @Override
73 | public void onClick(View v) {
74 | if (mCatsAdapter != null) {
75 | int select = (int) (Math.random() * 4);
76 |
77 | int[] resD = {R.mipmap.bg_nina, R.mipmap.bg_niju, R.mipmap.bg_yuki, R.mipmap.bg_kero};
78 | String[] resS = {"Nina", "Niju", "Yuki", "Kero"};
79 |
80 | DemoParallaxFragment newP = new DemoParallaxFragment();
81 | Bundle b = new Bundle();
82 | b.putInt("image", resD[select]);
83 | b.putString("name", resS[select]);
84 | newP.setArguments(b);
85 | mCatsAdapter.add(newP);
86 | }
87 | }
88 | });
89 | return v;
90 | }
91 |
92 | public void setAdapter(DemoParallaxAdapter catsAdapter) {
93 | mCatsAdapter = catsAdapter;
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/java/com/xgc1986/parallaxpagersample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.xgc1986.parallaxpagersample;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.FragmentActivity;
5 | import android.support.v4.view.ViewPager;
6 | import android.view.MenuItem;
7 |
8 | import com.xgc1986.parallaxPagerTransformer.ParallaxPagerTransformer;
9 |
10 | public class MainActivity extends FragmentActivity {
11 |
12 | ViewPager mPager;
13 | DemoParallaxAdapter mAdapter;
14 |
15 | /**
16 | * Called when the activity is first created.
17 | */
18 | @Override
19 | public void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.demo_activity_parallax);
22 |
23 | mPager = (ViewPager) findViewById(R.id.pager);
24 | mPager.setBackgroundColor(0xFF000000);
25 |
26 | ParallaxPagerTransformer pt = new ParallaxPagerTransformer((R.id.image));
27 | pt.setBorder(20);
28 | //pt.setSpeed(0.2f);
29 | mPager.setPageTransformer(false, pt);
30 |
31 | mAdapter = new DemoParallaxAdapter(getSupportFragmentManager());
32 | mAdapter.setPager(mPager); //only for this transformer
33 |
34 | Bundle bNina = new Bundle();
35 | bNina.putInt("image", R.mipmap.bg_nina);
36 | bNina.putString("name", "Nina");
37 | DemoParallaxFragment pfNina = new DemoParallaxFragment();
38 | pfNina.setArguments(bNina);
39 |
40 | Bundle bNiju = new Bundle();
41 | bNiju.putInt("image", R.mipmap.bg_niju);
42 | bNiju.putString("name", "Ninu Junior");
43 | DemoParallaxFragment pfNiju = new DemoParallaxFragment();
44 | pfNiju.setArguments(bNiju);
45 |
46 | Bundle bYuki = new Bundle();
47 | bYuki.putInt("image", R.mipmap.bg_yuki);
48 | bYuki.putString("name", "Yuki");
49 | DemoParallaxFragment pfYuki = new DemoParallaxFragment();
50 | pfYuki.setArguments(bYuki);
51 |
52 | Bundle bKero = new Bundle();
53 | bKero.putInt("image", R.mipmap.bg_kero);
54 | bKero.putString("name", "Kero");
55 | DemoParallaxFragment pfKero = new DemoParallaxFragment();
56 | pfKero.setArguments(bKero);
57 |
58 | mAdapter.add(pfNina);
59 | mAdapter.add(pfNiju);
60 | mAdapter.add(pfYuki);
61 | mAdapter.add(pfKero);
62 | mPager.setAdapter(mAdapter);
63 |
64 | if (getActionBar() != null) {
65 | getActionBar().setDisplayHomeAsUpEnabled(true);
66 | getActionBar().show();
67 | }
68 | }
69 |
70 | @Override
71 | public boolean onOptionsItemSelected(MenuItem item) {
72 | onBackPressed();
73 |
74 | return super.onOptionsItemSelected(item);
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/._.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/._.DS_Store
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/layout/demo_activity_parallax.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/layout/demo_fragment_parallax.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
13 |
22 |
23 |
34 |
35 |
36 |
46 |
47 |
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/mipmap-hdpi/bg_kero.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/mipmap-hdpi/bg_kero.jpg
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/mipmap-hdpi/bg_niju.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/mipmap-hdpi/bg_niju.jpg
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/mipmap-hdpi/bg_nina.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/mipmap-hdpi/bg_nina.jpg
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/mipmap-hdpi/bg_yuki.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/mipmap-hdpi/bg_yuki.jpg
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/mipmap-mdpi/bg_kero.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/mipmap-mdpi/bg_kero.jpg
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/mipmap-mdpi/bg_niju.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/mipmap-mdpi/bg_niju.jpg
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/mipmap-mdpi/bg_nina.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/mipmap-mdpi/bg_nina.jpg
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/mipmap-mdpi/bg_yuki.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/mipmap-mdpi/bg_yuki.jpg
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/mipmap-xhdpi/bg_kero.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/mipmap-xhdpi/bg_kero.jpg
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/mipmap-xhdpi/bg_niju.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/mipmap-xhdpi/bg_niju.jpg
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/mipmap-xhdpi/bg_nina.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/mipmap-xhdpi/bg_nina.jpg
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/mipmap-xhdpi/bg_yuki.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/mipmap-xhdpi/bg_yuki.jpg
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/mipmap-xxhdpi/bg_kero.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/mipmap-xxhdpi/bg_kero.jpg
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/mipmap-xxhdpi/bg_niju.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/mipmap-xxhdpi/bg_niju.jpg
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/mipmap-xxhdpi/bg_nina.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/mipmap-xxhdpi/bg_nina.jpg
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/mipmap-xxhdpi/bg_yuki.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/mipmap-xxhdpi/bg_yuki.jpg
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagersample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | parallaxpagersample
3 |
4 | Image of a cat
5 | +
6 |
7 |
--------------------------------------------------------------------------------
/parallaxpagersample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/parallaxpagertransformer/._.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformer/._.DS_Store
--------------------------------------------------------------------------------
/parallaxpagertransformer/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 | apply plugin: 'com.jfrog.bintray'
4 |
5 | def _siteUrl = 'https://github.com/xgc1986/ParallaxPagerTransformer' // Homepage URL of the library
6 | def _gitUrl = 'https://github.com/xgc1986/ParallaxPagerTransformer.git'
7 | def _issueUrl = 'https://github.com/xgc1986/ParallaxPagerTransformer/issues'
8 |
9 | def _name = 'ParallaxPagerLibrary'
10 | def _name2 = 'Parallax Pager'
11 | def _description = 'a Parallax Pager Library'
12 | def _labels = ['android', 'parallax', 'pager']
13 | def _version = "1.0.4"
14 |
15 | group = "com.xgc1986.android" // Maven Group ID for the artifact
16 | version _version
17 |
18 | android {
19 | compileSdkVersion 23
20 | buildToolsVersion "23.0.2"
21 | defaultConfig {
22 | minSdkVersion 16
23 | targetSdkVersion 23
24 | versionCode 1
25 | versionName _version
26 | }
27 | buildTypes {
28 | }
29 |
30 | compileOptions {
31 | sourceCompatibility JavaVersion.VERSION_1_7
32 | targetCompatibility JavaVersion.VERSION_1_7
33 | }
34 | }
35 |
36 | Properties properties = new Properties()
37 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
38 |
39 | bintray {
40 | user = properties.getProperty("bintray.user")
41 | key = properties.getProperty("bintray.apikey")
42 |
43 | configurations = ['archives']
44 |
45 | dryRun = false //Whether to run this as dry-run, without deploying
46 | publish = true //If version should be auto published after an upload
47 | pkg {
48 | repo = 'maven'
49 | name = _name
50 | desc = _description
51 | websiteUrl = _siteUrl
52 | issueTrackerUrl = _issueUrl
53 | vcsUrl = _gitUrl
54 | licenses = ['Apache-2.0']
55 | labels = _labels
56 | publicDownloadNumbers = true
57 |
58 | pkg {
59 | repo = "maven"
60 | name = _name
61 | websiteUrl = _siteUrl
62 | vcsUrl = _gitUrl
63 | licenses = ["Apache-2.0"]
64 | publish = true
65 | }
66 | }
67 |
68 | }
69 |
70 |
71 | install {
72 | repositories.mavenInstaller {
73 | // This generates POM.xml with proper parameters
74 | pom {
75 | project {
76 | packaging 'aar'
77 |
78 | // Add your description here
79 | name _name2
80 | url _siteUrl
81 |
82 | // Set your license
83 | licenses {
84 | license {
85 | name 'The Apache Software License, Version 2.0'
86 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
87 | }
88 | }
89 | developers {
90 | developer {
91 | id 'xgc1986'
92 | name 'Javier Gonzalez Cuadrado'
93 | email 'xgc1986@gmail.com'
94 | }
95 | }
96 | scm {
97 | connection _gitUrl
98 | developerConnection _gitUrl
99 | url _siteUrl
100 |
101 | }
102 | }
103 | }
104 | }
105 | }
106 |
107 | task sourcesJar(type: Jar) {
108 | from android.sourceSets.main.java.srcDirs
109 | classifier = 'sources'
110 | }
111 |
112 | task javadoc(type: Javadoc) {
113 | source = android.sourceSets.main.java.srcDirs
114 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
115 | }
116 |
117 | task javadocJar(type: Jar, dependsOn: javadoc) {
118 | classifier = 'javadoc'
119 | from javadoc.destinationDir
120 | }
121 | artifacts {
122 | archives javadocJar
123 | archives sourcesJar
124 | }
125 |
126 | dependencies {
127 | compile fileTree(dir: 'libs', include: ['*.jar'])
128 | compile 'com.android.support:appcompat-v7:23.2.1'
129 | }
130 |
131 |
132 |
133 |
134 |
135 |
136 |
--------------------------------------------------------------------------------
/parallaxpagertransformer/gradle.properties:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/parallaxpagertransformer/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | com.xg1986
6 | parallaxpagertransformer
7 | 0.3
8 | 2008
9 |
10 |
11 | The Apache Software License, Version 2.0
12 | http://www.apache.org/licenses/LICENSE-2.0.txt
13 | repo
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/parallaxpagertransformer/proguard-rules.txt:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/xgc1986/adt-bundle-mac-x86_64-20130522/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the ProGuard
5 | # include property in project.properties.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
--------------------------------------------------------------------------------
/parallaxpagertransformer/settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | false
11 |
12 | central
13 | bintray
14 | http://dl.bintray.com/xgc1986/maven
15 |
16 |
17 |
18 |
19 |
20 | false
21 |
22 | central
23 | bintray-plugins
24 | http://dl.bintray.com/xgc1986/maven
25 |
26 |
27 | bintray
28 |
29 |
30 |
31 | bintray
32 |
33 |
--------------------------------------------------------------------------------
/parallaxpagertransformer/src/._.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformer/src/._.DS_Store
--------------------------------------------------------------------------------
/parallaxpagertransformer/src/main/._.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformer/src/main/._.DS_Store
--------------------------------------------------------------------------------
/parallaxpagertransformer/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/parallaxpagertransformer/src/main/java/com/xgc1986/parallaxPagerTransformer/ParallaxPagerTransformer.java:
--------------------------------------------------------------------------------
1 | package com.xgc1986.parallaxPagerTransformer;
2 |
3 | import android.annotation.TargetApi;
4 | import android.os.Build;
5 | import android.support.v4.view.ViewPager;
6 | import android.util.Log;
7 | import android.view.View;
8 |
9 | public class ParallaxPagerTransformer implements ViewPager.PageTransformer {
10 |
11 | private int id;
12 | private int border = 0;
13 | private float speed = 0.2f;
14 |
15 | public ParallaxPagerTransformer(int id) {
16 | this.id = id;
17 | }
18 |
19 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
20 | @Override
21 | public void transformPage(View view, float position) {
22 |
23 | View parallaxView = view.findViewById(id);
24 |
25 | if (view == null ) {
26 | Log.w("ParallaxPager", "There is no view");
27 | }
28 |
29 | if (parallaxView != null && Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB ) {
30 | if (position > -1 && position < 1) {
31 | float width = parallaxView.getWidth();
32 | parallaxView.setTranslationX(-(position * width * speed));
33 | float sc = ((float)view.getWidth() - border)/ view.getWidth();
34 | if (position == 0) {
35 | view.setScaleX(1);
36 | view.setScaleY(1);
37 | } else {
38 | view.setScaleX(sc);
39 | view.setScaleY(sc);
40 | }
41 | }
42 | }
43 | }
44 |
45 | public void setBorder(int px) {
46 | border = px;
47 | }
48 |
49 | public void setSpeed(float speed) {
50 | this.speed = speed;
51 | }
52 | }
--------------------------------------------------------------------------------
/parallaxpagertransformersample/._.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/._.DS_Store
--------------------------------------------------------------------------------
/parallaxpagertransformersample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/parallaxpagertransformersample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.xgc1986.parallaxpagertransformersample"
9 | minSdkVersion 16
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | compile 'com.android.support:appcompat-v7:23.2.1'
25 | compile project(':parallaxpagertransformer')
26 | }
27 |
--------------------------------------------------------------------------------
/parallaxpagertransformersample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/xgc1986/adt-bundle-mac-x86_64-20130522/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/._.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/._.DS_Store
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/._.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/._.DS_Store
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/java/com/xgc1986/parallaxpagertransformersample/DemoParallaxAdapter.java:
--------------------------------------------------------------------------------
1 | package com.xgc1986.parallaxpagertransformersample;
2 |
3 | import android.support.v4.app.Fragment;
4 | import android.support.v4.app.FragmentManager;
5 | import android.support.v4.app.FragmentStatePagerAdapter;
6 | import android.support.v4.view.ViewPager;
7 |
8 | import java.util.ArrayList;
9 |
10 | public class DemoParallaxAdapter extends FragmentStatePagerAdapter {
11 |
12 | private ArrayList mFragments;
13 | private ViewPager mPager;
14 |
15 | public DemoParallaxAdapter(FragmentManager fm) {
16 | super(fm);
17 |
18 | mFragments = new ArrayList<>();
19 | }
20 |
21 | @Override
22 | public Fragment getItem(int i) {
23 | return mFragments.get(i);
24 | }
25 |
26 | @Override
27 | public int getCount() {
28 | return mFragments.size();
29 | }
30 |
31 | public void add(DemoParallaxFragment parallaxFragment) {
32 | parallaxFragment.setAdapter(this);
33 | mFragments.add(parallaxFragment);
34 | notifyDataSetChanged();
35 | mPager.setCurrentItem(getCount() - 1, true);
36 |
37 | }
38 |
39 | public void remove(int i) {
40 | mFragments.remove(i);
41 | notifyDataSetChanged();
42 | }
43 |
44 | public void remove(DemoParallaxFragment parallaxFragment) {
45 | mFragments.remove(parallaxFragment);
46 |
47 | int pos = mPager.getCurrentItem();
48 | notifyDataSetChanged();
49 |
50 | mPager.setAdapter(this);
51 | if (pos >= this.getCount()) {
52 | pos = this.getCount() - 1;
53 | }
54 | mPager.setCurrentItem(pos, true);
55 |
56 | }
57 |
58 | public int getItemPosition(Object object) {
59 | return POSITION_NONE;
60 | }
61 |
62 | public void setPager(ViewPager pager) {
63 | mPager = pager;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/java/com/xgc1986/parallaxpagertransformersample/DemoParallaxFragment.java:
--------------------------------------------------------------------------------
1 | package com.xgc1986.parallaxpagertransformersample;
2 |
3 | import android.graphics.Matrix;
4 | import android.os.Bundle;
5 | import android.support.v4.app.Fragment;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 |
12 | public class DemoParallaxFragment extends Fragment {
13 |
14 | private DemoParallaxAdapter mCatsAdapter;
15 |
16 | @Override
17 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
18 |
19 | super.onCreateView(inflater, container, savedInstanceState);
20 |
21 | View v = inflater.inflate(R.layout.demo_fragment_parallax, container, false);
22 | final ImageView image = (ImageView) v.findViewById(R.id.image);
23 |
24 | image.setImageResource(getArguments().getInt("image"));
25 | image.post(new Runnable() {
26 | @Override
27 | public void run() {
28 | Matrix matrix = new Matrix();
29 | matrix.reset();
30 |
31 | float wv = image.getWidth();
32 | float hv = image.getHeight();
33 |
34 | float wi = image.getDrawable().getIntrinsicWidth();
35 | float hi = image.getDrawable().getIntrinsicHeight();
36 |
37 | float width = wv;
38 | float height = hv;
39 |
40 | if (wi / wv > hi / hv) {
41 | matrix.setScale(hv / hi, hv / hi);
42 | width = wi * hv / hi;
43 | } else {
44 | matrix.setScale(wv / wi, wv / wi);
45 | height= hi * wv / wi;
46 | }
47 |
48 | matrix.preTranslate((wv - width) / 2, (hv - height) / 2);
49 | image.setScaleType(ImageView.ScaleType.MATRIX);
50 | image.setImageMatrix(matrix);
51 | }
52 | });
53 |
54 |
55 | TextView text = (TextView)v.findViewById(R.id.name);
56 | text.setText(getArguments().getString("name"));
57 |
58 | TextView more = (TextView)v.findViewById(R.id.more);
59 |
60 | more.setOnLongClickListener(new View.OnLongClickListener() {
61 | @Override
62 | public boolean onLongClick(View v) {
63 | if (mCatsAdapter != null) {
64 | mCatsAdapter.remove(DemoParallaxFragment.this);
65 | mCatsAdapter.notifyDataSetChanged();
66 | }
67 | return true;
68 | }
69 | });
70 |
71 | more.setOnClickListener(new View.OnClickListener() {
72 | @Override
73 | public void onClick(View v) {
74 | if (mCatsAdapter != null) {
75 | int select = (int) (Math.random() * 4);
76 |
77 | int[] resD = {R.mipmap.bg_nina, R.mipmap.bg_niju, R.mipmap.bg_yuki, R.mipmap.bg_kero};
78 | String[] resS = {"Nina", "Niju", "Yuki", "Kero"};
79 |
80 | DemoParallaxFragment newP = new DemoParallaxFragment();
81 | Bundle b = new Bundle();
82 | b.putInt("image", resD[select]);
83 | b.putString("name", resS[select]);
84 | newP.setArguments(b);
85 | mCatsAdapter.add(newP);
86 | }
87 | }
88 | });
89 | return v;
90 | }
91 |
92 | public void setAdapter(DemoParallaxAdapter catsAdapter) {
93 | mCatsAdapter = catsAdapter;
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/java/com/xgc1986/parallaxpagertransformersample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.xgc1986.parallaxpagertransformersample;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.FragmentActivity;
5 | import android.support.v4.view.ViewPager;
6 | import android.view.MenuItem;
7 |
8 | import com.xgc1986.parallaxPagerTransformer.ParallaxPagerTransformer;
9 |
10 | public class MainActivity extends FragmentActivity {
11 |
12 | ViewPager mPager;
13 | DemoParallaxAdapter mAdapter;
14 |
15 | /**
16 | * Called when the activity is first created.
17 | */
18 | @Override
19 | public void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.demo_activity_parallax);
22 |
23 | mPager = (ViewPager) findViewById(R.id.pager);
24 | mPager.setBackgroundColor(0xFF000000);
25 |
26 | ParallaxPagerTransformer pt = new ParallaxPagerTransformer((R.id.image));
27 | pt.setBorder(20);
28 | //pt.setSpeed(0.2f);
29 | mPager.setPageTransformer(false, pt);
30 |
31 | mAdapter = new DemoParallaxAdapter(getSupportFragmentManager());
32 | mAdapter.setPager(mPager); //only for this transformer
33 |
34 | Bundle bNina = new Bundle();
35 | bNina.putInt("image", R.mipmap.bg_nina);
36 | bNina.putString("name", "Nina");
37 | DemoParallaxFragment pfNina = new DemoParallaxFragment();
38 | pfNina.setArguments(bNina);
39 |
40 | Bundle bNiju = new Bundle();
41 | bNiju.putInt("image", R.mipmap.bg_niju);
42 | bNiju.putString("name", "Ninu Junior");
43 | DemoParallaxFragment pfNiju = new DemoParallaxFragment();
44 | pfNiju.setArguments(bNiju);
45 |
46 | Bundle bYuki = new Bundle();
47 | bYuki.putInt("image", R.mipmap.bg_yuki);
48 | bYuki.putString("name", "Yuki");
49 | DemoParallaxFragment pfYuki = new DemoParallaxFragment();
50 | pfYuki.setArguments(bYuki);
51 |
52 | Bundle bKero = new Bundle();
53 | bKero.putInt("image", R.mipmap.bg_kero);
54 | bKero.putString("name", "Kero");
55 | DemoParallaxFragment pfKero = new DemoParallaxFragment();
56 | pfKero.setArguments(bKero);
57 |
58 | mAdapter.add(pfNina);
59 | mAdapter.add(pfNiju);
60 | mAdapter.add(pfYuki);
61 | mAdapter.add(pfKero);
62 | mPager.setAdapter(mAdapter);
63 |
64 | if (getActionBar() != null) {
65 | getActionBar().setDisplayHomeAsUpEnabled(true);
66 | getActionBar().show();
67 | }
68 | }
69 |
70 | @Override
71 | public boolean onOptionsItemSelected(MenuItem item) {
72 | onBackPressed();
73 |
74 | return super.onOptionsItemSelected(item);
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/._.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/._.DS_Store
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/layout/demo_activity_parallax.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/layout/demo_fragment_parallax.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
13 |
21 |
22 |
33 |
34 |
35 |
45 |
46 |
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-hdpi/._ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-hdpi/._ic_launcher.png
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-hdpi/bg_kero.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-hdpi/bg_kero.jpg
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-hdpi/bg_niju.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-hdpi/bg_niju.jpg
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-hdpi/bg_nina.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-hdpi/bg_nina.jpg
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-hdpi/bg_yuki.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-hdpi/bg_yuki.jpg
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-mdpi/bg_kero.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-mdpi/bg_kero.jpg
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-mdpi/bg_niju.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-mdpi/bg_niju.jpg
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-mdpi/bg_nina.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-mdpi/bg_nina.jpg
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-mdpi/bg_yuki.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-mdpi/bg_yuki.jpg
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-xhdpi/bg_kero.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-xhdpi/bg_kero.jpg
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-xhdpi/bg_niju.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-xhdpi/bg_niju.jpg
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-xhdpi/bg_nina.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-xhdpi/bg_nina.jpg
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-xhdpi/bg_yuki.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-xhdpi/bg_yuki.jpg
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-xxhdpi/bg_kero.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-xxhdpi/bg_kero.jpg
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-xxhdpi/bg_niju.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-xxhdpi/bg_niju.jpg
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-xxhdpi/bg_nina.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-xxhdpi/bg_nina.jpg
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-xxhdpi/bg_yuki.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-xxhdpi/bg_yuki.jpg
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xgc1986/ParallaxPagerTransformer/2483fd51c6a2e6e6859e4a21272d9e92995e5407/parallaxpagertransformersample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | parallaxpagersample
3 |
4 | Image of a cat
5 | +
6 |
7 |
--------------------------------------------------------------------------------
/parallaxpagertransformersample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':parallaxpagertransformer', ':parallaxpagertransformersample'
--------------------------------------------------------------------------------