All Projects → AdevintaSpain → Parallax Layer Layout

AdevintaSpain / Parallax Layer Layout

Layered parallax effect to any Android views

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Parallax Layer Layout

Viewpagertransition
viewpager with parallax pages, together with vertical sliding (or click) and activity transition
Stars: ✭ 3,017 (+216.25%)
Mutual labels:  parallax
Parallaxbacklayout
无需改动原有activity只需要一个annotation轻松实现任意方向的滑动返回,默认提供微信滑动、跟随滑动、以及单个滑动,并且可以自定义滑动效果
Stars: ✭ 400 (-58.07%)
Mutual labels:  parallax
Paroller.js
Parallax scrolling jQuery plugin
Stars: ✭ 535 (-43.92%)
Mutual labels:  parallax
Locomotive Scroll
🛤 Detection of elements in viewport & smooth scrolling with parallax.
Stars: ✭ 4,231 (+343.5%)
Mutual labels:  parallax
Vue Flux
Image slider which comes with 20 cool transitions
Stars: ✭ 359 (-62.37%)
Mutual labels:  parallax
React Plx
React parallax component, powerful and lightweight
Stars: ✭ 469 (-50.84%)
Mutual labels:  parallax
Parallax Effect
🤹🏻‍♂️ Parallax effect in javascript using face tracking. An immersive view in 3d with webcam.
Stars: ✭ 275 (-71.17%)
Mutual labels:  parallax
Sticky Parallax Header
A simple React Native library, enabling to create a fully custom header for your iOS and Android apps.
Stars: ✭ 792 (-16.98%)
Mutual labels:  parallax
React Native Parallax Scroll
Parallax scroll view for react-native
Stars: ✭ 385 (-59.64%)
Mutual labels:  parallax
Smooth Scrolling
smooth scrolling and parallax effects on scroll
Stars: ✭ 514 (-46.12%)
Mutual labels:  parallax
Tilt.js
A tiny 60+fps parallax tilt hover effect for jQuery.
Stars: ✭ 3,442 (+260.8%)
Mutual labels:  parallax
Transformer page view
PageTransformer for flutter
Stars: ✭ 341 (-64.26%)
Mutual labels:  parallax
Rnparallax
A react native scroll view component with Parallax header :p
Stars: ✭ 474 (-50.31%)
Mutual labels:  parallax
React Native App Intro
react-native-app-intro is a react native component implementing a parallax effect welcome page using base on react-native-swiper , similar to the one found in Google's app like Sheet, Drive, Docs...
Stars: ✭ 3,169 (+232.18%)
Mutual labels:  parallax
Vue Parallax
🌌 Vue.js component for parallax image scroll effects
Stars: ✭ 569 (-40.36%)
Mutual labels:  parallax
React Native Collapsing Toolbar
react-native wrapper for android CollapsingToolbarLayout
Stars: ✭ 280 (-70.65%)
Mutual labels:  parallax
Immersivedetailsample
A sample application show how to realize immersive parallax effect header like Google Play Store
Stars: ✭ 457 (-52.1%)
Mutual labels:  parallax
Cz Parallax
Simple and tiny jQuery plugin for Parallax effect.
Stars: ✭ 10 (-98.95%)
Mutual labels:  parallax
Parade
Parallax Scroll-Jacking Effects Engine for iOS / tvOS
Stars: ✭ 754 (-20.96%)
Mutual labels:  parallax
Motus
Animation library that mimics CSS keyframes when scrolling.
Stars: ✭ 502 (-47.38%)
Mutual labels:  parallax

Parallax Layer Layout

Bintray Build Status

Lets you add layered parallax effect to your Android views or images based on things like device rotation.

We use it at InfoJobs for our error and empty states.



Usage | Download | How it works | Customize | Contribute

Usage

In your layout wrap your layers inside a ParallaxLayerLayout:

<com.schibsted.spain.parallaxlayerlayout.ParallaxLayerLayout
    android:id="@+id/parallax"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <View
        android:id="@+id/layer_3"
        android:layout_width="180dp"
        android:layout_height="180dp"
        android:background="@color/colorPrimaryDark" />
    <View
        android:id="@+id/layer_2"
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:background="@color/colorPrimary" />
    <View
        android:id="@+id/layer_1"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:background="@color/colorAccent" />
            
    </com.schibsted.spain.parallaxlayerlayout.ParallaxLayerLayout>

In your code create a TranslationUpdater and link it with the ParallaxLayerLayout:

sensorTranslationUpdater = new SensorTranslationUpdater(this);
parallaxLayout.setTranslationUpdater(sensorTranslationUpdater);

// onResume
sensorTranslationUpdater.registerSensorManager();

// onPause
sensorTranslationUpdater.unregisterSensorManager();

Note: Just for the sensor updater you'll need to register and unregister it in your onResume/onPause.

# Download Grab the latest version from jCenter:

dependencies {
  compile 'com.schibsted.spain:parallax-layer-layout:1.1.2'
}

How it works

The layout applies a maximum offset to each of its views, starting with a base offset and adding one offset increment for each layer.

The higher view in the Z index is the closest one from the user perspective so it will only move with the base offset. The further the view from the user, the more it will move.

The parallax effect is applied based on an horizontal and vertical translations, ranging from -1.0 to 1.0. This translation is provided by an external TranslationUpdater. The library includes some:

  • SensorTranslationUpdater: Updates the translation based on the orientation sensors (roll and pitch).
  • AnimatedTranslationUpdater: Applies the translation automatically as a continuous animation.

Customize

Parallax offset

You can change the default offset for the effect within your xml with the attributes parallaxOffsetBase and parallaxOffsetIncrement:

<com.schibsted.spain.parallaxlayerlayout.ParallaxLayerLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:parallaxOffsetBase="10dp"
    app:parallaxOffsetIncrement="5dp">

The defaul values are 10dp for the base and 5dp for the increment

Vertical and horizontal effect scale

Sometimes you might want to reduce or increase the effect for vertical or horizontal movement.

<com.schibsted.spain.parallaxlayerlayout.ParallaxLayerLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:parallaxScaleVertical="0.25"
        >

In this example the views will move vertically a 25% with respect to what they move horizontally.

Note: The parallax scale doesn't scale the views, but rather the parallax movement

Custom Z index

By default the parallax effect is applied in the views Z index. This means that the last view in the layout will be the one closer to the user, and so it will move less; and the first view will be the furthest and will move more.

If you need a different parallax order you can change this behavior by overriding the views index with the attribute layout_parallaxZIndex:

<com.schibsted.spain.parallaxlayerlayout.ParallaxLayerLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <View
        android:id="@+id/layer_2"
        android:layout_width="180dp"
        android:layout_height="180dp"
        android:background="@color/colorPrimaryDark"
        app:layout_parallaxZIndex="1" />

    <View
        android:id="@+id/layer_3"
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:background="@color/colorPrimary"
        app:layout_parallaxZIndex="2" />

    <View
        android:id="@+id/layer_1"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:background="@color/colorAccent"
        app:layout_parallaxZIndex="0" />

</com.schibsted.spain.parallaxlayerlayout.ParallaxLayerLayout>

Static layer

You can disable the parallax effect in any of the views to stop them from moving with the attribute layout_parallaxEnabled:

<View
    android:id="@+id/layer_static"
    android:layout_width="180dp"
    android:layout_height="180dp"
    android:background="@color/colorPrimaryDark"
    app:layout_parallaxEnabled="false" />

Contribute

For bugs, requests, questions and discussions please use Github Issues.

Attributions

This library was developed by Rafa Vázquez with the idea of moving images from Alex Bailón for the Infojobs' Android application.

Device requirements

This layout needs a gyroscope powered device. Sadly, there are some low-end phones that doesn't have it. In that case, the layered will appear like a static image.

License

Copyright 2016 Schibsted Classified Media Spain S.L.


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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].