Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

florent37/AndroidParallax

Repository files navigation

AndroidParallax

Android app on Google Play

Parallax on Android in the simplest way

Video

Android app on Google Play

Download

compile ('com.github.florent37:androidparallax:1.0.1@aar'){
        transitive=true
}

Usage

Simply replace your ScrollView with a com.github.florent37.parallax.ScrollView

Then add a parallax=FLOAT_VALUE into your view's tag

<com.github.florent37.parallax.ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <!-- ...your usual views... -->

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:scaleType="centerCrop"
        android:src="@drawable/background"

        android:tag="parallax=0.3" />

    <TextView
        style="@style/MyTitle"
        android:layout_width="match_parent"
        android:layout_height="160dp"
        android:gravity="center"
        android:text="My awesome title"

        android:tag="parallax=0.5" />

    <!-- ...your usual views... -->

</com.github.florent37.parallax.ScrollView>

And no additionnal lines into the activity !

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

}

ParallaxView

If you don't want to play with the android:tag attributes, then you cas simple surround your view with a ParallaxView.

A ParallaxView can move vertically of horizontally Parallax attributes defines a parallax factor for this view

  • parallaxVertical < 0 : the view will move slower than the scroll
  • parallaxVertical > 0 : the view will move faster than the scroll
<com.github.florent37.parallax.ParallaxView
         android:layout_width="match_parent"
         android:layout_height="wrap_content"

         app:parallaxVertical="1.1"

         >

         <!-- Your View -->

</com.github.florent37.parallax.ScrollView>

Horizontal translation

  • parallaxHorizontal < 0 : the view will move to the right
  • parallaxHorizontal > 0 : the view will move to the left
<com.github.florent37.parallax.ParallaxView
         android:layout_width="match_parent"
         android:layout_height="wrap_content"

         app:parallaxHorizontal="1.1"

         >

          <!-- Your View -->

</com.github.florent37.parallax.ScrollView>

TODO

  • Add RecyclerView Parallax
  • Add fading / parallax effect on a toolbar

Community

Looking for contributors, feel free to fork !

Credits

Author: Florent Champigny

Android app on Google Play Follow me on Google+ Follow me on Twitter Follow me on LinkedIn

License

Copyright 2015 florent37, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Parallax on Android in the simplest way

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages