Code Monkey home page Code Monkey logo

discrollview's Introduction

Discrollview

Regularly, I am pleasantly surprised by websites using a pattern I called the discrollver pattern. I'm sure you already know what I'm talking about but if not, http://vimeo.com/player is a good example. When you scroll, widgets appear from nowhere by fade, translation or scale.

With DiscrollView, I wanted to import this pattern on Android. This is an 0.0.1 alpha version because you have to do all the transformation work (fade, translation, scale etc) yourself base on a ratio value. I'm going to add some transformation presets (translation from left to right + fade in for example) to make the library more ready to use for lazy developers.

Animated gif (on youtube)

Try out the sample APK here

Or browse the source code of the sample application for a complete example of use.

Including in your project

Just add the library to your application as a library project.

Compatibilty

API 14+

Usage

Using the library is simple, just look at the source code of the provided sample here

build.gradle

compile 'com.github.flavienlaurent.discrollview:library:0.0.2@aar'

The main layout

You must use the DiscrollViewContent view.

<com.flavienlaurent.discrollview.lib.DiscrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:discrollve="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.flavienlaurent.discrollview.lib.DiscrollViewContent
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <!-- here you put discrollvable views -->

    </com.flavienlaurent.discrollview.lib.DiscrollViewContent>

</com.flavienlaurent.discrollview.lib.DiscrollView>

Discrollvable views

You can apply some transformation on discroll:

  • alpha
  • scale
  • translation (fromLeft, fromBottom, fromRight, fromTop) fromLeft+fromRight and fromBottom+fromTop are forbidden couples.
  • bgcolor
discrollve:discrollve_alpha="true"
discrollve:discrollve_translation="fromLeft|fromBottom"
discrollve:discrollve_scaleX="true"
discrollve:discrollve_scaleY="true"
discrollve:discrollve_fromBgColor="#88EE66"
discrollve:discrollve_toBgColor="#000000"
discrollve:discrollve_threshold="0.3"

The threshold attribute is used to trigger the discrollve at a specified ratio. For example, if threshold=0.3, the discrollve starts when the ratio >= 0.3.

A simple example

<com.flavienlaurent.discrollview.lib.DiscrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:discrollve="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.flavienlaurent.discrollview.lib.DiscrollViewContent
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="600dp"
            android:background="@android:color/white"
            android:textColor="@android:color/black"
            android:padding="25dp"
            android:textSize="72sp"
            android:gravity="center"
            android:fontFamily="serif"
            android:text="Do you love cheese?" />

        <View
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:background="#007788"
            discrollve:discrollve_alpha="true"
            discrollve:discrollve_threshold="0.3" />

        <ImageView
            android:layout_width="200dp"
            android:layout_height="120dp"
            discrollve:discrollve_alpha="true"
            discrollve:discrollve_translation="fromLeft|fromBottom"
            android:src="@drawable/cheese1" />

        <View
            android:layout_width="match_parent"
            android:layout_height="200dp"
            discrollve:discrollve_fromColor="#88EE66"
            discrollve:discrollve_toColor="#000000" />

        <ImageView
            android:layout_width="220dp"
            android:layout_height="110dp"
            android:layout_gravity="right"
            android:src="@drawable/cheese2"
            discrollve:discrollve_translation="fromRight" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="20dp"
            android:fontFamily="serif"
            android:gravity="center"
            android:text="When the cheese comes out everybody's happy pecorino red leicester"
            android:textSize="18sp"
            discrollve:discrollve_alpha="true"
            discrollve:discrollve_translation="fromBottom" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="20dp"
            android:layout_gravity="center"
            android:src="@drawable/ilovecheese_heart"
            discrollve:discrollve_scaleX="true"
            discrollve:discrollve_scaleY="true"  />

    </com.flavienlaurent.discrollview.lib.DiscrollViewContent>
</com.flavienlaurent.discrollview.lib.DiscrollView>

License

Copyright 2013 Flavien Laurent

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.

discrollview's People

Contributors

flavienlaurent avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discrollview's Issues

listviewscroll

hello
i tried to make it work on listview but i could not
1- i create a listview adapter
2- i create a single row layout and give the for example title textview discrollve:discrollve_translation="fromRight"
but it not works you know
instead of using scrolview and put the childs one by one
i want it to be a listview that it can loads many data.

my english is too poor can you please help me with this one and change my life? beg you

discrollve_fromColor and discrollve_toColor

My problem is :
Error:(45) No resource identifier found for attribute 'discrollve_fromColor' in package 'app.test'
Error:(45) No resource identifier found for attribute 'discrollve_toColor' in package 'app.test'

Lot of issues while importing

Lot of incompatible code and a unique way of importing from maven is totally cumbersome to understand. Please update with latest versions of build.gradle. I am trying if it works.

Gradle sync error in android studio

when I put

compile 'com.github.flavienlaurent.discrollview:library:0.0.2@aar'

in my build.gradle file with my other libraries I get an error during the gradle sync saying

"Could not find com.github.flavienlaurent.discrollview:library:0.0.2."

any idea?

No mention of API compatibility

Love the feel of this library, but It'd be great to display in the readme what API versions can make use of it. For example, I want to know: can I use it in my gingerbread app?

Incorrect order

When adding ca. 7 - 10 views to the DiscrollViewContent some views are animated after they usually should. (Instead of view A is animated before view B, view B is first animated)

Compatibilty API 14

Could you explain why Compatibilty to API 14+ ?
I complie your project and I don't find why it require api 14

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.