Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/AdevintaSpain/Parallax-Layer-Layout
Layered parallax effect to any Android views
https://github.com/AdevintaSpain/Parallax-Layer-Layout
android-library parallax
Last synced: about 1 month ago
JSON representation
Layered parallax effect to any Android views
- Host: GitHub
- URL: https://github.com/AdevintaSpain/Parallax-Layer-Layout
- Owner: AdevintaSpain
- Created: 2016-07-27T08:22:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-02-26T12:03:22.000Z (almost 4 years ago)
- Last Synced: 2024-05-22T06:13:27.495Z (7 months ago)
- Topics: android-library, parallax
- Language: Java
- Homepage:
- Size: 1.94 MB
- Stars: 955
- Watchers: 25
- Forks: 91
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-github-android-ui - Parallax-Layer-Layout - Android分层视差效果 (滚动视差(Parallex))
README
# Parallax Layer Layout
[![Bintray](https://img.shields.io/bintray/v/schibstedspain/maven/parallax-layer-layout.svg?maxAge=2592000)](https://bintray.com/schibstedspain/maven/parallax-layer-layout/) [![Build Status](https://travis-ci.org/SchibstedSpain/Parallax-Layer-Layout.svg?branch=master)](https://travis-ci.org/SchibstedSpain/Parallax-Layer-Layout)
Lets you add layered parallax effect to your Android views or images based on things like device rotation.
We use it at [InfoJobs](https://play.google.com/store/apps/details?id=net.infojobs.mobile.android) for our error and empty states.
Usage
|
Download
|
How it works
|
Customize
|
Contribute# Usage
In your layout wrap your layers inside a **ParallaxLayerLayout**:
```xml
```In your code create a **TranslationUpdater** and link it with the *ParallaxLayerLayout*:
```java
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:```groovy
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 offsetYou can change the default offset for the effect within your xml with the attributes **parallaxOffsetBase** and **parallaxOffsetIncrement**:
```xml
```
*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.
```xml
```
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**:
```xml
```
## Static layer
You can disable the parallax effect in any of the views to stop them from moving with the attribute **layout_parallaxEnabled**:
```xml
```
# Contribute
For bugs, requests, questions and discussions please use [Github Issues](https://github.com/SchibstedSpain/parallax-layer-layout/issues).# Attributions
This library was developed by [Rafa Vázquez](https://github.com/Sloy/) with the idea of moving images from [Alex Bailón](https://github.com/abailon) for the [Infojobs' Android application](https://play.google.com/store/apps/details?id=net.infojobs.mobile.android).# 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 athttp://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.
```