Giter Site home page Giter Site logo

androidparallax's Introduction

AndroidParallax

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

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.

androidparallax's People

Contributors

florent37 avatar

Watchers

Michael jentsch avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.