Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/zoonooz/simple-view-behavior

Simple and easy way to deal with CoordinatorLayout Behavior
https://github.com/zoonooz/simple-view-behavior

android android-ui animation appbarlayout coordinatorlayout

Last synced: 1 day ago
JSON representation

Simple and easy way to deal with CoordinatorLayout Behavior

Lists

README

        

[![Build Status](https://travis-ci.org/zoonooz/simple-view-behavior.svg?branch=master)](https://travis-ci.org/zoonooz/simple-view-behavior)

# simple-view-behavior

Simple View Behavior for Android [CoordinatorLayout](http://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.html).

This library provide you easy ways to config and setup the view behavior without creating subclass of
[Behavior](http://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior.html)

## Installation

```
compile 'com.zoonref:simple-view-behavior:1.0'
```

## Usage
You can setup behavior effect by using only xml option.

1. set the layout behavior to this library class `app:layout_behavior="com.zoonref.SimpleViewBehavior"`
2. set the dependency view by specify resource id by `app:dependsOn="@+id/{your view id}"`
3. set the type of dependency `app:dependType="{x,y,width,height}"`
4. set the dependency view target value according to the type you choose `app:dependTargetXXX="{value}"`
5. set the target appearance that you want your view to animate to

There are **two** ways to specify the animation when the dependency view changed.

### 1. xml

```

```

This View will depend on the `y` positon of `@+id/app_bar` which is AppBarLayout. View will animation from current state of AppBarLayout until
y position of AppBarLayout is `-156dp` with the animation, View will animate alpha to `app:targetAlpha="1"` rotate x to `app:targetRotateX="0"`

**Don't forget to add** `xmlns:app="http://schemas.android.com/apk/res-auto"`

**The output will be**

### 2. view animation resource file

When you use animation, all of animate target option from xml will be ignored.

for example

```

```
```



```

**The output will be**

### Options

You can see all available option at [attrs.xml](https://github.com/zoonooz/simple-view-behavior/blob/master/library/src/main/res/values/attrs.xml)

## Author

Amornchai Kanokpullwad, [@zoonref](https://twitter.com/zoonref)

## License

simple-view-behavior is available under the MIT license. See the LICENSE file for more info.