DMIV aims to provide a flexible and customizable instrument for automated images moving on display. It provides scroll, gyroscope or time based moving. But you can create your own evaluator.

Overview

Logo DexMovingImageView

Android Arsenal

DMIV aims to provide a flexible and customizable instrument for automated images moving on display. It provides scroll, gyroscope or time based moving. But you can create your own evaluator.

Screenshot

Features

  • Google Calendar ImageView
  • Google NewsStand Moving ImageView
  • Structured system to create your own objects or use the ones provided
  • Flexible way to create your own effect
  • Android 1.5+ support

Upcoming Changes

  • Ken Burns Effect

Downloads

Demo app

Screenshot Screenshot Screenshot Screenshot Screenshot Screenshot

Setup

DexMovingImageView is pushed to Maven Central as an AAR. Add the following to build.gradle.

    dependencies {
        compile 'it.dex.dexmovingimageview:dexmovingimageviewlib:0.1.0'
    }

or the following using Maven:

    <dependency>
        <groupid>it.dex.dexmovingimageview</groupid>
        <artifactid>dexmovingimageviewlib</artifactid>
        <version>0.1.0</version>
        <type>aar</type>
    </dependency>

Usage

##Simple

This section show you how to use the provided views without questioning how it works.

This library provides 2 views:

  • DexCrossFadeImageView: It allows you to add a fading transition when changing the source drawable with specified transition duration in milliseconds. It also provides a way to slideshow multiple images;
  • DexMovingImageView: It extends the DexCrossFadeImageView, so it inherits every property from it and add lots of new features.

###DexCrossFadeImageView The view has 2 parameters:

  • TransitionDurationMillis (default: 300)
  • StillImageDurationMillis (default: 3000)

They both have their own getters and setters. ####Single Image First of all you can set your timings, if needed. Then you can start a transition by calling the following methods:

    dexCrossFadeImageView.setFadingImageResource(R.drawable.my_image);
    dexCrossFadeImageView.setFadingImageDrawable(myDrawable);
    dexCrossFadeImageView.setFadingImageBitmap(myBitmap);

####Multiple Images Or you can set a List or an array of:

  • Resources (integers)
  • Drawables
  • Bitmaps

and then call the start() or start(int transitionDurationMillis, int stillImageTransitionMillis) methods. You can do the same using the images_array attribute:

    <it.dex.movingimageviewlib.DexCrossFadeImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/my_image"
        dex:images_array="@array/my_images"
        dex:loop="true"
        dex:still_image_duration_millis="1000"
        dex:transition_duration_millis="500" />

You can pause the transition by calling the pause() method.

###DexMovigImageView

You can treat it like any other ImageView or DexCrossFadeImageView, but you need to add the following to set the desired behaviour:

  • Evaluator
  • ValuesGenerator
  • Drawers

The next two subsections show you how to add two popular view in your app.

####Calendar-like View This is the simplest way to use it. Simply add the following attributes to your view:

    <it.dex.movingimageviewlib.DexMovingImageView
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        dex:zoom="2.0"
        dex:evaluator="scrollBased"
        dex:generator="base"
        dex:drawer="scale|translate" />

Change zoom value to increase or decrease scaling: this way you can enhance the scrolling effect.

####NewsStand-like View This is the same as above, but with different evaluator and generator:

    <it.dex.movingimageviewlib.DexMovingImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        dex:evaluator="timeBased"
        dex:images_array="@array/my_images"
        dex:generator="zoomed"
        dex:angle="130"
        dex:loop="true"
        dex:zoom="1.65"
        dex:drawer="scale|translate"
        dex:still_image_duration_millis="3000"
        dex:transition_duration_millis="1000" />

Use the OnEventOccurred interface to listen to every change during execution. You can set a new CrossFading image or change tint or change angle, etc. The events returned are:

  1. START
  2. FIRST QUARTER
  3. MIDDLE
  4. THIRD QUARTER
  5. END
    @Override
    public void onEventOccurred(View view, Evaluator evaluator, Evaluator.EVENT_STATUS eventStatus, int occurrenceCount) {
        switch (eventStatus) {
            case FIRST_QUARTER:
                //Your code here:
                break;
            case THIRD_QUARTER:
                //Your code here:
                break;
            case END:
                //Your code here:
                break;
            case MIDDLE:
                //Your code here:
                break;
        }
    }

##Advanced This section show you how to add any new unimplemented feature. First af all you need to know how it works: a DexMovingImageView is composed by 3 main elements that describe how to do something:

  1. Evaluators (only one at a time): they describe what originates the basic values;
  2. Values Generators (only one at a time): they describe how to modify the basic values coming from evaluators:
  3. Drawers (one or more): they describe what property change must be applied to the view.

Everytime the view is invalidated, the evaluator evaluate new basic values, ValuesGenerator changes them and drawer apply the new values to the view.

###Evaluators

Currently there are 4 kind of evaluator in this library:

  • Simple: It always returns the default values, so the single property can be applied based on what drawers you use;
  • Scroll: It returns the position of the view relative to the display (the left top corner coordinates);
  • Time: It returns increasing values from 0 to 360, based on a speed values;
  • Gyroscope: It returns x, y, z values from Gyroscope.

You can create your own Evaluator by extending the Evaluator class and implementing the following methods:

    @Override
    protected void onCreate(View view) {
        //Your Code here
    }

    @Override
    public float evaluateX(View view) {
        //Your Code here
        return x;
    }

    @Override
    public float evaluateY(View view) {
        //Your Code here
        return y;
    }

    @Override
    protected void onDestroy(View view) {
        //Your Code here
    }

An evaluator has its lifecycle, so you can optimize the use of any external services or API you use: For example: for the TimeEvaluator a TimerTask is started in the onCreate() method and it's stopped in the onDestroy() one. You don't have to worry about calling this methods because the superclass does it for you. If you need to start or stop those APIs you used, you can call the start() and stop() methods.

The following methods are not abstract and their default implementation returns the default values set to the view:

    @Override
    public float evaluateAngle(View view, float defaultAngle) {
        //Your Code here
    }

    @Override
    public float evaluateZoom(View view, float defaultZoom) {
        //Your Code here
    }

You should also find a way to call the OnEventOccurred implementation:

    if (getOnEventOccurred() != null && isNotifyEvent()) {
        if (someClause) {
            getOnEventOccurred().onEventOccurred(getView(), this, EVENT_STATUS.END, ++endLoopCount);
        } else if (someOtherClause) {
            getOnEventOccurred().onEventOccurred(getView(), this, EVENT_STATUS.START, ++startLoopCount);
        } else if (someOtherClause) {
            getOnEventOccurred().onEventOccurred(getView(), this, EVENT_STATUS.MIDDLE, ++middleLoopCount);
        } else if (someOtherClause) {
            getOnEventOccurred().onEventOccurred(getView(), this, EVENT_STATUS.FIRST_QUARTER, ++firstQuarterLoopCount);
        } else if (someOtherClause) {
            getOnEventOccurred().onEventOccurred(getView(), this, EVENT_STATUS.THIRD_QUARTER, ++secondQuarterLoopCount);
        }
    }

A DexMovingImageView has one only Evaluator, so you can specify the enum value or the complete class path inside xml file:

    <it.dex.movingimageviewlib.DexMovingImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/my_image"
        dex:evaluator="timeBased"
        dex:images_array="@array/my_images"
        dex:generator="zoomed"
        dex:angle="130"
        dex:loop="true"
        dex:zoom="1.65"
        dex:drawer="scale|translate"
        dex:still_image_duration_millis="3000"
        dex:transition_duration_millis="1000" />

or

    <it.dex.movingimageviewlib.DexMovingImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/my_image"
        dex:evaluator="it.dex.movingimageview.MyEvaluator"
        dex:images_array="@array/my_images"
        dex:generator="zoomed"
        dex:angle="130"
        dex:loop="true"
        dex:zoom="1.65"
        dex:drawer="scale|translate"
        dex:still_image_duration_millis="3000"
        dex:transition_duration_millis="1000" />

###Values Generators

The provided values generators are:

  • Base: It generates x and y values;
  • Angled: It generates the same Base values, plus Angle values;
  • ZoomedAngled: It generates the same as Angled, but it generates zoom values too.

A Generator deals with manipulating values to return the desired one using some sort of logical pattern. To create your own Generator your class must extend the ValuesGenerator one and implement the following methods:

    @Override
    public float getX(float x) {
        //Your Code here
        return newX;
    }

    @Override
    public float getY(float y) {
        //Your Code here
        return newY;
    }

    @Override
    public float getAngle(float angle, float defaultAngle) {
        //Your Code here
        return newAngle;
    }

    @Override
    public float getZoom(float zoom, float defaultZoom) {
        //Your Code here
        return newZoom;
    }

A DexMovingImageView has one only ValuesGenerator, so you can specify the enum value or the complete class path inside xml file:

    <it.dex.movingimageviewlib.DexMovingImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/my_image"
        dex:evaluator="timeBased"
        dex:images_array="@array/my_images"
        dex:generator="zoomed"
        dex:angle="130"
        dex:loop="true"
        dex:zoom="1.65"
        dex:drawer="scale|translate"
        dex:still_image_duration_millis="3000"
        dex:transition_duration_millis="1000" />

or

    <it.dex.movingimageviewlib.DexMovingImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/my_image"
        dex:evaluator="timeBased"
        dex:images_array="@array/my_images"
        dex:generator="it.dex.movingimageview.MyValuesGenerator"
        dex:angle="130"
        dex:loop="true"
        dex:zoom="1.65"
        dex:drawer="scale|translate"
        dex:still_image_duration_millis="3000"
        dex:transition_duration_millis="1000" />

###Drawers

Three properties can be modified based on the generated values. So you can use the following:

  • Scale: It scales the view content using "zoom" value in both width and height;
  • Translate: It translate the view inside its container using x and y values returned by ValuesGenerator;
  • Rotate: It rotate the view using "angle" value.

A DexMovingImageView can have one or more Drawers, so you can specify the values inside xml file:

    <it.dex.movingimageviewlib.DexMovingImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/my_image"
        dex:evaluator="timeBased"
        dex:images_array="@array/my_images"
        dex:generator="zoomed"
        dex:angle="130"
        dex:loop="true"
        dex:zoom="1.65"
        dex:drawer="scale|rotate|translate"
        dex:still_image_duration_millis="3000"
        dex:transition_duration_millis="1000" />

Credits

Author: Diego Grancini ([email protected])

Any hint, suggestion, improvement or comment will be appreciated

Follow me on Google+ Follow me on Twitter Follow me on LinkedIn Follow me on GitHub

License

Copyright 2014-2015 Diego Grancini

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.
You might also like...
A library for Android provides blurred drop shadows to ImageView similar to iOS image backdrop shadows
A library for Android provides blurred drop shadows to ImageView similar to iOS image backdrop shadows

A library for Android provides blurred drop shadows to ImageView similar to iOS image backdrop shadows.Provides fast canvas draw as no renderscript needed .The similar shadow blurred effects can also be seen in iOS Music App.

RasmView - an Android drawing view; it provides a view that allows users to draw on top of a bitmap.
RasmView - an Android drawing view; it provides a view that allows users to draw on top of a bitmap.

RasmView RasmView is an Android drawing library; it provides a view that allows users to draw on top of a bitmap. Demo https://www.youtube.com/watch?v

Create parallax and any other transformation effects on scrolling android ImageView
Create parallax and any other transformation effects on scrolling android ImageView

Android Parallax Image View Creates effect such as vertical parallax, horizontal parallax etc. on android ImageView when it's being vertically or hori

Create circular ImageView in Android in the simplest way possible
Create circular ImageView in Android in the simplest way possible

CircularImageView This is an Android project allowing to realize a circular ImageView in the simplest way possible. USAGE To make a circular ImageView

Subclass of ImageView that 'morphs' into a circle shape and can rotates. Useful to be used as album cover in Music apps. :dvd::notes:
Subclass of ImageView that 'morphs' into a circle shape and can rotates. Useful to be used as album cover in Music apps. :dvd::notes:

Music Cover View A Subclass of ImageView that 'morphs' into a circle shape and can rotates. Useful to be used as album cover in Music apps. It's used

Android filters based on OpenGL (idea from GPUImage for iOS)

GPUImage for Android Idea from: iOS GPUImage framework Goal is to have something as similar to GPUImage as possible. Vertex and fragment shaders are e

Android filters based on OpenGL (idea from GPUImage for iOS)

GPUImage for Android Idea from: iOS GPUImage framework Goal is to have something as similar to GPUImage as possible. Vertex and fragment shaders are e

BadgedImageview allow you show a badge into a Imageview.
BadgedImageview allow you show a badge into a Imageview.

BadgedImageview BadgedImageview allow you show a badge into a Imageview. I just extracted the widgets from Plaid app developed by Nick Butcher(https:/

Big image viewer supporting pan and zoom, with very little memory usage and full featured image loading choices. Powered by Subsampling Scale Image View, Fresco, Glide, and Picasso. Even with gif and webp support! 🍻
Big image viewer supporting pan and zoom, with very little memory usage and full featured image loading choices. Powered by Subsampling Scale Image View, Fresco, Glide, and Picasso. Even with gif and webp support! 🍻

BigImageViewer Big image viewer supporting pan and zoom, with very little memory usage and full featured image loading choices. Powered by Subsampling

Comments
  • Fix broken headings in Markdown files

    Fix broken headings in Markdown files

    GitHub changed the way Markdown headings are parsed, so this change fixes it.

    See bryant1410/readmesfix for more information.

    Tackles bryant1410/readmesfix#1

    opened by bryant1410 0
  • Set zoom causes view to shrink

    Set zoom causes view to shrink

    If you start with a zoom of 2 in an xml, then change the zoom to 1 programmatically, the view shrinks. Shouldn't the view maintain its position and the zoom of the drawable in the view should change?

    <it.dex.movingimageviewlib.DexMovingImageView
        android:id="@+id/image"
        android:layout_width="match_parent"
        android:layout_height="420dp"
        android:layout_alignParentTop="true"
        app:drawer="scale"
        app:zoom="2"
        app:angle="0"
        app:generator="base"
        app:evaluator="simple"
        tools:src="@drawable/hotdogs1400" />
    

    That is the xml I have, I would like to scale this image so that it keeps its position but shrinks in size. Similar to a ken burns effect like shown here https://www.youtube.com/watch?v=nNTiyRDhlRY

    opened by srodenberg 1
  • Translate drawer moves canvas off screen

    Translate drawer moves canvas off screen

    This created undesired behavior where translated image gets partially off the screen leaving blank regions underneath. Could you at least have a property to control this behavior?

    opened by Exaper 2
Owner
Diego Grancini
Diego Grancini
Custom ImageView for moving image around the screen (Android)

MovingImageView Create a custom ImageView for moving image around the screen. Usage To use MovingImageView, add the module into your project and start

Albert Grobas 819 Nov 18, 2022
Slider-Gallery-Zoom: image slider for android supporting indicator and auto scroll with clicking on image

image slider supporting indicator and auto scroll with clicking on image to open full screen image slider swipe and pinch zoom gestures like gallery,just pass your images and the position of the current image.

Mahmoud Elian 3 May 28, 2022
Android library (AAR). Highly configurable, easily extendable deep zoom view for displaying huge images without loss of detail. Perfect for photo galleries, maps, building plans etc.

Subsampling Scale Image View A custom image view for Android, designed for photo galleries and displaying huge images (e.g. maps and building plans) w

null 7.4k Jan 8, 2023
Android library project for cropping images

I guess people are just cropping out all the sadness An Android library project that provides a simple image cropping Activity, based on code from AOS

Jamie McDonald 4.5k Dec 29, 2022
Custom view for circular images in Android while maintaining the best draw performance

CircularImageView Custom view for circular images in Android while maintaining the best draw performance Usage To make a circular ImageView, add this

Pkmmte Xeleon 1.2k Dec 28, 2022
Android ImageView that handles animated GIF images

GifImageView Android ImageView that handles Animated GIF images Usage In your build.gradle file: dependencies { compile 'com.felipecsl:gifimageview:

Felipe Lima 1.1k Mar 9, 2021
A gallery used to host an array of images

ImageGallery Overview A gallery used to host an array of images You can add one or more images to the gallery Support for using Palette to set the bac

Etienne Lawlor 645 Dec 18, 2022
An open source Android library that allows the visualization of large images with gesture capabilities

ByakuGallery ByakuGallery is an open source Android library that allows the visualization of large images with gesture capabilities. This lib is based

Diego Lima 311 Dec 4, 2022
Customizable Android full screen image viewer for Fresco library supporting "pinch to zoom" and "swipe to dismiss" gestures. Made by Stfalcon

This project is no longer supported. If you're able to switch from Fresco to any other library that works with the Android's ImageView, please migrate

Stfalcon LLC 1.8k Dec 19, 2022
Image Picker with Customizable UI for Android, Pick an image from Gallery

Image Picker A Image Picker Library for Android (Supports Android 12) with fully

null 2 May 29, 2022