├── .gitignore ├── LICENSE ├── ParallaxScroll ├── AndroidManifest.xml ├── build.gradle ├── proguard-project.txt ├── project.properties ├── res │ └── values │ │ ├── about_libraries_def.xml │ │ └── attrs.xml └── src │ └── com │ └── nirhart │ └── parallaxscroll │ └── views │ ├── ParallaxExpandableListView.java │ ├── ParallaxListView.java │ ├── ParallaxListViewHelper.java │ ├── ParallaxScrollView.java │ └── ParallaxedView.java ├── ParallaxScrollExample ├── AndroidManifest.xml ├── build.gradle ├── libs │ └── android-support-v4.jar ├── proguard-project.txt ├── project.properties ├── res │ ├── drawable-xhdpi │ │ ├── github.png │ │ └── ic_launcher.png │ ├── drawable │ │ └── item_background.xml │ ├── layout │ │ ├── activity_main.xml │ │ ├── expand_list_multiple_parallax.xml │ │ ├── expand_list_one_parallax.xml │ │ ├── item.xml │ │ ├── item_child.xml │ │ ├── list_multiple_parallax.xml │ │ ├── list_one_parallax.xml │ │ ├── scroll_multiple_parallax.xml │ │ ├── scroll_one_parallax.xml │ │ └── scroll_one_parallax_alpha.xml │ ├── menu │ │ └── main.xml │ ├── values-sw600dp │ │ └── dimens.xml │ ├── values-sw720dp-land │ │ └── dimens.xml │ ├── values-v11 │ │ └── styles.xml │ ├── values-v14 │ │ └── styles.xml │ └── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml └── src │ └── com │ └── nirhart │ └── parallaxscrollexample │ ├── CustomExpandableListAdapter.java │ ├── CustomListAdapter.java │ ├── MainActivity.java │ ├── MultipleParallaxExpandableListView.java │ ├── MultipleParallaxListView.java │ ├── MultipleParallaxScrollView.java │ ├── SingleParallaxAlphaScrollView.java │ ├── SingleParallaxExpandableListView.java │ ├── SingleParallaxListView.java │ └── SingleParallaxScrollView.java ├── README.md ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | **/build/ 15 | 16 | # Local configuration file (sdk path, etc) 17 | local.properties 18 | 19 | # Eclipse project files 20 | .classpath 21 | .project 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Intellij project files 27 | *.iml 28 | *.ipr 29 | *.iws 30 | .idea/ 31 | 32 | # Gradle 33 | .gradle/ 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Nir Hartmann 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /ParallaxScroll/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /ParallaxScroll/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion '25.0.3' 6 | 7 | compileOptions { 8 | sourceCompatibility JavaVersion.VERSION_1_7 9 | targetCompatibility JavaVersion.VERSION_1_7 10 | } 11 | 12 | sourceSets { 13 | main { 14 | manifest { 15 | srcFile 'AndroidManifest.xml' 16 | } 17 | java { 18 | srcDir 'src' 19 | } 20 | res { 21 | srcDir 'res' 22 | } 23 | assets { 24 | srcDir 'assets' 25 | } 26 | resources { 27 | srcDir 'src' 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /ParallaxScroll/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /ParallaxScroll/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-19 15 | android.library=true 16 | -------------------------------------------------------------------------------- /ParallaxScroll/res/values/about_libraries_def.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Nir Hartmann 5 | https://github.com/nirhart 6 | parallaxscroll 7 | Parallax ListView and ScrollView for Android. 8 | 1.0 9 | https://github.com/nirhart/ParallaxScroll 10 | mit 11 | true 12 | https://github.com/nirhart/ParallaxScroll.git 13 | 14 | -------------------------------------------------------------------------------- /ParallaxScroll/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /ParallaxScroll/src/com/nirhart/parallaxscroll/views/ParallaxExpandableListView.java: -------------------------------------------------------------------------------- 1 | package com.nirhart.parallaxscroll.views; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.view.View; 6 | import android.widget.ExpandableListView; 7 | 8 | public class ParallaxExpandableListView extends ExpandableListView { 9 | 10 | private ParallaxListViewHelper helper; 11 | 12 | public ParallaxExpandableListView(Context context, AttributeSet attrs, int defStyle) { 13 | super(context, attrs, defStyle); 14 | init(context, attrs); 15 | } 16 | 17 | public ParallaxExpandableListView(Context context, AttributeSet attrs) { 18 | super(context, attrs); 19 | init(context, attrs); 20 | } 21 | 22 | protected void init(Context context, AttributeSet attrs) { 23 | helper = new ParallaxListViewHelper(context, attrs, this); 24 | super.setOnScrollListener(helper); 25 | } 26 | 27 | @Override 28 | public void setOnScrollListener(OnScrollListener l) { 29 | helper.setOnScrollListener(l); 30 | } 31 | 32 | public void addParallaxedHeaderView(View v) { 33 | super.addHeaderView(v); 34 | helper.addParallaxedHeaderView(v); 35 | } 36 | 37 | public void addParallaxedHeaderView(View v, Object data, boolean isSelectable) { 38 | super.addHeaderView(v, data, isSelectable); 39 | helper.addParallaxedHeaderView(v, data, isSelectable); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ParallaxScroll/src/com/nirhart/parallaxscroll/views/ParallaxListView.java: -------------------------------------------------------------------------------- 1 | package com.nirhart.parallaxscroll.views; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.view.View; 6 | import android.widget.ListView; 7 | 8 | public class ParallaxListView extends ListView { 9 | 10 | private ParallaxListViewHelper helper; 11 | 12 | public ParallaxListView(Context context, AttributeSet attrs, int defStyle) { 13 | super(context, attrs, defStyle); 14 | init(context, attrs); 15 | } 16 | 17 | public ParallaxListView(Context context, AttributeSet attrs) { 18 | super(context, attrs); 19 | init(context, attrs); 20 | } 21 | 22 | protected void init(Context context, AttributeSet attrs) { 23 | helper = new ParallaxListViewHelper(context, attrs, this); 24 | super.setOnScrollListener(helper); 25 | } 26 | 27 | @Override 28 | public void setOnScrollListener(OnScrollListener l) { 29 | helper.setOnScrollListener(l); 30 | } 31 | 32 | public void addParallaxedHeaderView(View v) { 33 | super.addHeaderView(v); 34 | helper.addParallaxedHeaderView(v); 35 | } 36 | 37 | public void addParallaxedHeaderView(View v, Object data, boolean isSelectable) { 38 | super.addHeaderView(v, data, isSelectable); 39 | helper.addParallaxedHeaderView(v, data, isSelectable); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ParallaxScroll/src/com/nirhart/parallaxscroll/views/ParallaxListViewHelper.java: -------------------------------------------------------------------------------- 1 | package com.nirhart.parallaxscroll.views; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.util.AttributeSet; 6 | import android.view.View; 7 | import android.view.animation.TranslateAnimation; 8 | import android.widget.AbsListView; 9 | import android.widget.AbsListView.OnScrollListener; 10 | import android.widget.ListView; 11 | 12 | import com.nirhart.parallaxscroll.R; 13 | 14 | public class ParallaxListViewHelper implements OnScrollListener { 15 | 16 | private static final float DEFAULT_ALPHA_FACTOR = -1F; 17 | private static final float DEFAULT_PARALLAX_FACTOR = 1.9F; 18 | private static final boolean DEFAULT_IS_CIRCULAR = false; 19 | private float parallaxFactor = DEFAULT_PARALLAX_FACTOR; 20 | private float alphaFactor = DEFAULT_ALPHA_FACTOR; 21 | private ParallaxedView parallaxedView; 22 | private boolean isCircular; 23 | private OnScrollListener listener = null; 24 | private ListView listView; 25 | 26 | protected ParallaxListViewHelper(Context context, AttributeSet attrs, ListView listView) { 27 | init(context, attrs, listView); 28 | } 29 | 30 | protected void init(Context context, AttributeSet attrs, ListView listView) { 31 | this.listView = listView; 32 | TypedArray typeArray = context.obtainStyledAttributes(attrs, R.styleable.ParallaxScroll); 33 | this.parallaxFactor = typeArray.getFloat(R.styleable.ParallaxScroll_parallax_factor, DEFAULT_PARALLAX_FACTOR); 34 | this.alphaFactor = typeArray.getFloat(R.styleable.ParallaxScroll_alpha_factor, DEFAULT_ALPHA_FACTOR); 35 | this.isCircular = typeArray.getBoolean(R.styleable.ParallaxScroll_circular_parallax, DEFAULT_IS_CIRCULAR); 36 | typeArray.recycle(); 37 | } 38 | 39 | protected void setOnScrollListener(OnScrollListener l) { 40 | this.listener = l; 41 | } 42 | 43 | protected void addParallaxedHeaderView(View v) { 44 | addParallaxedView(v); 45 | } 46 | 47 | protected void addParallaxedHeaderView(View v, Object data, boolean isSelectable) { 48 | addParallaxedView(v); 49 | } 50 | 51 | protected void addParallaxedView(View v) { 52 | this.parallaxedView = new ListViewParallaxedItem(v); 53 | } 54 | 55 | protected void parallaxScroll() { 56 | if (isCircular) 57 | circularParallax(); 58 | else 59 | headerParallax(); 60 | } 61 | 62 | private void circularParallax() { 63 | if (listView.getChildCount() > 0) { 64 | int top = -listView.getChildAt(0).getTop(); 65 | if (top >= 0) { 66 | fillParallaxedViews(); 67 | setFilters(top); 68 | } 69 | } 70 | } 71 | 72 | private void headerParallax() { 73 | if (parallaxedView != null) { 74 | if (listView.getChildCount() > 0) { 75 | int top = -listView.getChildAt(0).getTop(); 76 | if (top >= 0) { 77 | setFilters(top); 78 | } 79 | } 80 | } 81 | } 82 | 83 | private void setFilters(int top) { 84 | parallaxedView.setOffset((float)top / parallaxFactor); 85 | if (alphaFactor != DEFAULT_ALPHA_FACTOR) { 86 | float alpha = (top <= 0) ? 1 : (100 / ((float)top * alphaFactor)); 87 | parallaxedView.setAlpha(alpha); 88 | } 89 | parallaxedView.animateNow(); 90 | } 91 | 92 | private void fillParallaxedViews() { 93 | if (parallaxedView == null || parallaxedView.is(listView.getChildAt(0)) == false) { 94 | if (parallaxedView != null) { 95 | resetFilters(); 96 | parallaxedView.setView(listView.getChildAt(0)); 97 | } else { 98 | parallaxedView = new ListViewParallaxedItem(listView.getChildAt(0)); 99 | } 100 | } 101 | } 102 | 103 | private void resetFilters() { 104 | parallaxedView.setOffset(0); 105 | if (alphaFactor != DEFAULT_ALPHA_FACTOR) 106 | parallaxedView.setAlpha(1F); 107 | parallaxedView.animateNow(); 108 | } 109 | 110 | @Override 111 | public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { 112 | parallaxScroll(); 113 | if (this.listener != null) 114 | this.listener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount); 115 | } 116 | 117 | @Override 118 | public void onScrollStateChanged(AbsListView view, int scrollState) { 119 | if (this.listener != null) 120 | this.listener.onScrollStateChanged(view, scrollState); 121 | } 122 | 123 | protected class ListViewParallaxedItem extends ParallaxedView { 124 | 125 | public ListViewParallaxedItem(View view) { 126 | super(view); 127 | } 128 | 129 | @Override 130 | protected void translatePreICS(View view, float offset) { 131 | addAnimation(new TranslateAnimation(0, 0, offset, offset)); 132 | } 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /ParallaxScroll/src/com/nirhart/parallaxscroll/views/ParallaxScrollView.java: -------------------------------------------------------------------------------- 1 | package com.nirhart.parallaxscroll.views; 2 | 3 | import java.util.ArrayList; 4 | 5 | import android.content.Context; 6 | import android.content.res.TypedArray; 7 | import android.util.AttributeSet; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.ScrollView; 11 | 12 | import com.nirhart.parallaxscroll.R; 13 | 14 | public class ParallaxScrollView extends ScrollView { 15 | 16 | private static final int DEFAULT_PARALLAX_VIEWS = 1; 17 | private static final float DEFAULT_INNER_PARALLAX_FACTOR = 1.9F; 18 | private static final float DEFAULT_PARALLAX_FACTOR = 1.9F; 19 | private static final float DEFAULT_ALPHA_FACTOR = -1F; 20 | private int numOfParallaxViews = DEFAULT_PARALLAX_VIEWS; 21 | private float innerParallaxFactor = DEFAULT_PARALLAX_FACTOR; 22 | private float parallaxFactor = DEFAULT_PARALLAX_FACTOR; 23 | private float alphaFactor = DEFAULT_ALPHA_FACTOR; 24 | private ArrayList parallaxedViews = new ArrayList(); 25 | 26 | public ParallaxScrollView(Context context, AttributeSet attrs, int defStyle) { 27 | super(context, attrs, defStyle); 28 | init(context, attrs); 29 | } 30 | 31 | public ParallaxScrollView(Context context, AttributeSet attrs) { 32 | super(context, attrs); 33 | init(context, attrs); 34 | } 35 | 36 | public ParallaxScrollView(Context context) { 37 | super(context); 38 | } 39 | 40 | protected void init(Context context, AttributeSet attrs) { 41 | TypedArray typeArray = context.obtainStyledAttributes(attrs, R.styleable.ParallaxScroll); 42 | this.parallaxFactor = typeArray.getFloat(R.styleable.ParallaxScroll_parallax_factor, DEFAULT_PARALLAX_FACTOR); 43 | this.alphaFactor = typeArray.getFloat(R.styleable.ParallaxScroll_alpha_factor, DEFAULT_ALPHA_FACTOR); 44 | this.innerParallaxFactor = typeArray.getFloat(R.styleable.ParallaxScroll_inner_parallax_factor, DEFAULT_INNER_PARALLAX_FACTOR); 45 | this.numOfParallaxViews = typeArray.getInt(R.styleable.ParallaxScroll_parallax_views_num, DEFAULT_PARALLAX_VIEWS); 46 | typeArray.recycle(); 47 | } 48 | 49 | @Override 50 | protected void onFinishInflate() { 51 | super.onFinishInflate(); 52 | makeViewsParallax(); 53 | } 54 | 55 | private void makeViewsParallax() { 56 | if (getChildCount() > 0 && getChildAt(0) instanceof ViewGroup) { 57 | ViewGroup viewsHolder = (ViewGroup) getChildAt(0); 58 | int numOfParallaxViews = Math.min(this.numOfParallaxViews, viewsHolder.getChildCount()); 59 | for (int i = 0; i < numOfParallaxViews; i++) { 60 | ParallaxedView parallaxedView = new ScrollViewParallaxedItem(viewsHolder.getChildAt(i)); 61 | parallaxedViews.add(parallaxedView); 62 | } 63 | } 64 | } 65 | 66 | @Override 67 | protected void onScrollChanged(int l, int t, int oldl, int oldt) { 68 | super.onScrollChanged(l, t, oldl, oldt); 69 | float parallax = parallaxFactor; 70 | float alpha = alphaFactor; 71 | for (ParallaxedView parallaxedView : parallaxedViews) { 72 | parallaxedView.setOffset(((float)t / parallax), Math.round(t/parallaxFactor)); 73 | parallax *= innerParallaxFactor; 74 | if (alpha != DEFAULT_ALPHA_FACTOR) { 75 | float fixedAlpha = (t <= 0) ? 1 : (100 / ((float)t * alpha)); 76 | parallaxedView.setAlpha(fixedAlpha); 77 | alpha /= alphaFactor; 78 | } 79 | parallaxedView.animateNow(); 80 | } 81 | } 82 | 83 | protected class ScrollViewParallaxedItem extends ParallaxedView { 84 | 85 | public ScrollViewParallaxedItem(View view) { 86 | super(view); 87 | } 88 | 89 | @Override 90 | protected void translatePreICS(View view, float offset) { 91 | view.offsetTopAndBottom((int)offset - lastOffset); 92 | lastOffset = (int)offset; 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /ParallaxScroll/src/com/nirhart/parallaxscroll/views/ParallaxedView.java: -------------------------------------------------------------------------------- 1 | package com.nirhart.parallaxscroll.views; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.graphics.Rect; 5 | import android.os.Build; 6 | import android.view.View; 7 | import android.view.animation.AlphaAnimation; 8 | import android.view.animation.Animation; 9 | import android.view.animation.AnimationSet; 10 | 11 | import java.lang.ref.WeakReference; 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | public abstract class ParallaxedView { 16 | private static boolean isAPI11 = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; 17 | private static boolean isAPI18 = Build.VERSION.SDK_INT >= 18; 18 | protected WeakReference view; 19 | protected int lastOffset; 20 | protected List animations; 21 | protected Rect clippingRect = new Rect(); 22 | protected boolean firstRectGet = false; 23 | private int lastScrollY; 24 | 25 | abstract protected void translatePreICS(View view, float offset); 26 | 27 | public ParallaxedView(View view) { 28 | this.lastOffset = 0; 29 | this.animations = new ArrayList(); 30 | this.view = new WeakReference(view); 31 | } 32 | 33 | public boolean is(View v) { 34 | return (v != null && view != null && view.get() != null && view.get().equals(v)); 35 | } 36 | 37 | @SuppressLint("NewApi") 38 | public void setOffset(float offset) { 39 | View view = this.view.get(); 40 | if (view != null) 41 | if (isAPI11) { 42 | view.setTranslationY(offset); 43 | } else { 44 | translatePreICS(view, offset); 45 | } 46 | } 47 | 48 | @SuppressLint("NewApi") 49 | public void setOffset(float offset, int originalScrollY) { 50 | View view = this.view.get(); 51 | if (view != null) 52 | if (isAPI11) { 53 | if (!firstRectGet) { 54 | clippingRect.top = view.getTop(); 55 | clippingRect.left = view.getLeft(); 56 | clippingRect.right = view.getRight(); 57 | clippingRect.bottom = view.getBottom(); 58 | firstRectGet = true; 59 | } 60 | if (lastScrollY == 0) { 61 | lastScrollY = originalScrollY; 62 | } 63 | int delta = lastScrollY - originalScrollY; 64 | clippingRect.bottom += delta; 65 | view.setTranslationY(Math.round(offset)); 66 | if (isAPI18) view.setClipBounds(clippingRect); 67 | lastScrollY = originalScrollY; 68 | if (isAPI18) { 69 | if (clippingRect.bottom <= clippingRect.top) { 70 | view.setVisibility(View.INVISIBLE); 71 | } else { 72 | view.setVisibility(View.VISIBLE); 73 | } 74 | } 75 | } else { 76 | translatePreICS(view, offset); 77 | } 78 | } 79 | 80 | public void setAlpha(float alpha) { 81 | View view = this.view.get(); 82 | if (view != null) 83 | if (isAPI11) { 84 | view.setAlpha(alpha); 85 | } else { 86 | alphaPreICS(view, alpha); 87 | } 88 | } 89 | 90 | protected synchronized void addAnimation(Animation animation) { 91 | animations.add(animation); 92 | } 93 | 94 | protected void alphaPreICS(View view, float alpha) { 95 | addAnimation(new AlphaAnimation(alpha, alpha)); 96 | } 97 | 98 | protected synchronized void animateNow() { 99 | View view = this.view.get(); 100 | if (view != null) { 101 | AnimationSet set = new AnimationSet(true); 102 | for (Animation animation : animations) 103 | if (animation != null) 104 | set.addAnimation(animation); 105 | set.setDuration(0); 106 | set.setFillAfter(true); 107 | view.setAnimation(set); 108 | set.start(); 109 | animations.clear(); 110 | } 111 | } 112 | 113 | public void setView(View view) { 114 | this.view = new WeakReference(view); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /ParallaxScrollExample/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 34 | 35 | 36 | 39 | 40 | 41 | 44 | 45 | 46 | 49 | 50 | 51 | 54 | 55 | 56 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /ParallaxScrollExample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | defaultConfig { 5 | versionCode 6 6 | versionName '1.5.1' 7 | 8 | minSdkVersion 8 9 | targetSdkVersion 25 10 | } 11 | 12 | compileSdkVersion 25 13 | buildToolsVersion '25.0.3' 14 | 15 | sourceSets { 16 | main { 17 | manifest { 18 | srcFile 'AndroidManifest.xml' 19 | } 20 | java { 21 | srcDir 'src' 22 | } 23 | res { 24 | srcDir 'res' 25 | } 26 | assets { 27 | srcDir 'assets' 28 | } 29 | resources { 30 | srcDir 'src' 31 | } 32 | } 33 | } 34 | } 35 | dependencies { 36 | // internal deps (the sub projects dependencies are transitive to this one) 37 | compile project(':ParallaxScroll') 38 | compile 'com.android.support:support-v4:19.0.1' 39 | } 40 | -------------------------------------------------------------------------------- /ParallaxScrollExample/libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirhart/ParallaxScroll/dd53d1f9d18d097e53e8c2270fa4e77ad439c7a4/ParallaxScrollExample/libs/android-support-v4.jar -------------------------------------------------------------------------------- /ParallaxScrollExample/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /ParallaxScrollExample/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-19 15 | android.library.reference.1=../ParallaxScroll 16 | -------------------------------------------------------------------------------- /ParallaxScrollExample/res/drawable-xhdpi/github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirhart/ParallaxScroll/dd53d1f9d18d097e53e8c2270fa4e77ad439c7a4/ParallaxScrollExample/res/drawable-xhdpi/github.png -------------------------------------------------------------------------------- /ParallaxScrollExample/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirhart/ParallaxScroll/dd53d1f9d18d097e53e8c2270fa4e77ad439c7a4/ParallaxScrollExample/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ParallaxScrollExample/res/drawable/item_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /ParallaxScrollExample/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 11 | 12 |