Create parallax and any other transformation effects on scrolling android ImageView

Overview

Android Parallax Image View

Codacy Badge Android Arsenal API

Creates effect such as vertical parallax, horizontal parallax etc. on android ImageView when it's being vertically or horizontally scrolled (moving) on the screen.

References:

Screenshot

Setup

  • Step 1 Add repository into root build.gradle
allprojects {
    repositories {
    ...
    maven {
        url 'https://jitpack.io' }
    }
}
  • Step 2 Add library dependency into app build.gradle
dependencies {
    implementation 'com.github.abdularis:parallaximageview:1.1'
}

Usage

  • Create vertical parallax image view
<com.github.abdularis.piv.VerticalScrollParallaxImageView
    android:id="@+id/image_view"
    android:layout_width="200dp"
    android:layout_height="170dp"
    android:src="@drawable/img1"/>
  • Create Horizontal parallax image view
<com.github.abdularis.piv.HorizontalScrollParallaxImageView
    android:id="@+id/image_view"
    android:layout_width="200dp"
    android:layout_height="170dp"
    android:src="@drawable/img1"/>
  • Create and customize effect on your own
<com.github.abdularis.piv.ScrollTransformImageView
    android:id="@+id/image_view"
    android:layout_width="200dp"
    android:layout_height="170dp"
    android:src="@drawable/img1"/>

In the java/kotlin code you can set the effect (transformer) manually. There are three built-in effect classes, VerticalParallaxTransformer, HorizontalParallaxTransformer, HorizontalScaleTransformer.

Java code

ScrollTransformImageView img = findViewById(R.id.image_view);

// create horizontal scale effect
img.setViewTransformer(new HorizontalScaleTransformer())

// create vertical or horizontal parallax effect manually
// img.setViewTransformer(new VerticalParallaxTransformer())
// img.setViewTransformer(new HorizontalParallaxTransformer())
//
// the VerticalParallaxImageView or HorizontalParallaxImageView are nothing but the ScrollTransformImageView with coresponding parallax effect

You can create your own custom effect by extending ViewTransformer.

public class CustomTransformer extends ViewTransformer {
    @Override
    public void onAttached(@NotNull ScrollTransformImageView view) {
        // do something when this transformer is set into image view
    }

    @Override
    public void onDetached(@NotNull ScrollTransformImageView view) {
        // do something when this transformer is remove from image view
    }

    @Override
    public void apply(@NotNull ScrollTransformImageView view, @NotNull Canvas canvas, int viewX, int viewY) {
        // do transformation effect or so, this would be called everytime image view move/scrolled
    }
}

License

MIT License

You might also like...
Adds touch functionality to Android ImageView.

TouchImageView for Android Capabilities TouchImageView extends ImageView and supports all of ImageView’s functionality. In addition, TouchImageView ad

Custom shaped android imageview components
Custom shaped android imageview components

Shape Image View Provides a set of custom shaped android imageview components, and a framework to define more shapes. Implements both shader and bitma

Android ImageView replacement which allows image loading from URLs or contact address book, with caching

Smart Image View for Android SmartImageView is a drop-in replacement for Android’s standard ImageView which additionally allows images to be loaded fr

Implements pinch-zoom, rotate, pan as an ImageView for Android 2.1+

GestureImageView This is a simple Android View class which provides basic pinch and zoom capability for images. Can be used as a replacement for a sta

Android ImageView that handles animated GIF images
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:

Android ImageView that supports different radii on each corner.
Android ImageView that supports different radii on each corner.

SelectableRoundedImageView Note that this project is no longer maintained. Android ImageView that supports different radii on each corner. It also sup

ImageView with a tag on android
ImageView with a tag on android

SimpleTagImageView ImageView with a tag in android. So it's a ImageView. Demo ####Warning:When you set the round radius,the simpletagimageview scale t

Custom ImageView for moving image around the screen (Android)
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

Flickable ImageView for Android. It's like a view of twitter's detail image.
Flickable ImageView for Android. It's like a view of twitter's detail image.

FlickableView Flickable ImageView for Android. It's like a view of twitter's detail image. It's possible that other views animate with FlickableView.

Comments
  • Logo Design Offer For ParallaxImageView

    Logo Design Offer For ParallaxImageView

    Hello Sir. I'm a UI/UX and Graphics Designer. I want propose a logo for your github project. Would you mind if I propose logo for your application as my Open Source Contribution?

    Thanks before. Regards, @iqbalhood

    opened by iqbalhood 7
  • Paralaxx not working in Glide

    Paralaxx not working in Glide

    Hi I'm using your library,I have little issue. Parallax effect not working when I try to create rounded corners image with Glide Here is a my Glide code

    // val radius = context.resources.getDimensionPixelSize(R.dimen.dimen_p_15) // GlideApp.with(context) // .load(imageUrl) // .transform(CenterCrop(),RoundedCorners(radius)) // .transition(DrawableTransitionOptions.withCrossFade()).into(imageView)](url)

    do you have any solutions ? thanks

    opened by Bekakk 1
  • Crash when image loaded asyncroneously with Glide

    Crash when image loaded asyncroneously with Glide

    java.lang.IllegalStateException: view.drawable must not be null at com.github.abdularis.piv.transformer.VerticalParallaxTransformer.apply(VerticalParallaxTransformer.kt:23) at com.github.abdularis.piv.ScrollTransformImageView.onDraw(ScrollTransformImageView.kt:41) at android.view.View.draw(View.java:16217) at android.view.View.updateDisplayListIfDirty(View.java:15214) at android.view.View.draw(View.java:15987) at android.view.ViewGroup.drawChild(ViewGroup.java:3612) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402) at android.view.View.updateDisplayListIfDirty(View.java:15209) at android.view.View.draw(View.java:15987) at android.view.ViewGroup.drawChild(ViewGroup.java:3612) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402) at android.view.View.draw(View.java:16220) at android.view.View.updateDisplayListIfDirty(View.java:15214) at android.view.View.draw(View.java:15987) at android.view.ViewGroup.drawChild(ViewGroup.java:3612) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402) at android.view.View.draw(View.java:16220) at android.view.View.updateDisplayListIfDirty(View.java:15214) at android.view.View.draw(View.java:15987) at android.view.ViewGroup.drawChild(ViewGroup.java:3612) at android.support.v7.widget.RecyclerView.drawChild(RecyclerView.java:4703) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402) at android.view.View.draw(View.java:16220) at android.support.v7.widget.RecyclerView.draw(RecyclerView.java:4107) at android.view.View.updateDisplayListIfDirty(View.java:15214) at android.view.View.draw(View.java:15987) at android.view.ViewGroup.drawChild(ViewGroup.java:3612) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402) at android.view.View.updateDisplayListIfDirty(View.java:15209) at android.view.View.draw(View.java:15987) at android.view.ViewGroup.drawChild(ViewGroup.java:3612) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402) at android.view.View.updateDisplayListIfDirty(View.java:15209) at android.view.View.draw(View.java:15987) at android.view.ViewGroup.drawChild(ViewGroup.java:3612) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402) at android.view.View.updateDisplayListIfDirty(View.java:15209) at android.view.View.draw(View.java:15987) at android.view.ViewGroup.drawChild(ViewGroup.java:3612) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402) at android.view.View.draw(View.java:16220) at android.view.View.updateDisplayListIfDirty(View.java:15214) at android.view.View.draw(View.java:15987) at android.view.ViewGroup.drawChild(ViewGroup.java:3612) at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1366) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402) at android.view.View.updateDisplayListIfDirty(View.java:15209) at android.view.View.draw(View.java:15987) at android.view.ViewGroup.drawChild(ViewGroup.java:3612) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402) at android.view.View.updateDisplayListIfDirty(View.java:15209) at android.view.View.draw(View.java:15987) at android.view.ViewGroup.drawChild(ViewGroup.java:3612) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402) at android.view.View.updateDisplayListIfDirty(View.java:15209) at android.view.View.draw(View.java:15987) at android.view.ViewGroup.drawChild(ViewGroup.java:3612) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402) at android.view.View.updateDisplayListIfDirty(View.java:15209) at android.view.View.draw(View.java:15987) at android.view.ViewGroup.drawChild(ViewGroup.java:3612) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402) at android.view.View.updateDisplayListIfDirty(View.java:15209) at android.view.View.draw(View.java:15987) at android.view.ViewGroup.drawChild(ViewGroup.java:3612) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3402) at android.view.View.draw(View.java:16220)

    opened by eugeneroz 1
  • Edit Readme.md and Adding Logo

    Edit Readme.md and Adding Logo

    Hello Sir , I have modified the Readme.md file and adding logo to your project. If you have some request please contact me on github or send email to [email protected]

    opened by iqbalhood 0
Releases(1.1)
Owner
Aris
🐣
Aris
Apply custom effects on view backgrounds

View Filters At the beginning the only purpose was to blur all layers below. Now you can do more : Blur background views easily Create custom filters

Mad Mirrajabi 180 Nov 25, 2022
ImageView and FrameLayout with gestures control and position animation

GestureViews ImageView and FrameLayout with gestures control and position animation. Main goal of this library is to make images viewing process as sm

Alex Vasilkov 2.3k Dec 30, 2022
Android ImageView widget with zoom and pan capabilities

ImageViewTouch for Android ImageViewTouch is an android ImageView widget with zoom and pan capabilities. This is an implementation of the ImageView wi

Alessandro Crugnola 1.9k Jan 4, 2023
Crop and Rounded Corners added to an ImageView.

SuperImageView Extra features for your ImageView provided in a modularized way Documentation for v2 coming this week. CropImageView An ImageView that

César Díez Sánchez 657 Jan 5, 2023
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

André Mion 254 Dec 23, 2022
Crop and Rounded Corners added to an ImageView.

SuperImageView Extra features for your ImageView provided in a modularized way Documentation for v2 coming this week. CropImageView An ImageView that

César Díez Sánchez 658 Dec 1, 2022
Custom ImageView for android with polygon shape (Android)

PolygonImageView Create a custom ImageView with polygonal forms. Usage To use PolygonImageView, add the module into your project and start to build xm

Albert Grobas 531 Dec 25, 2022
Implementation of ImageView for Android that supports zooming, by various touch gestures.

PhotoView PhotoView aims to help produce an easily usable implementation of a zooming Android ImageView. [ Dependency Add this in your root build.grad

Baseflow 18.4k Dec 30, 2022
A circular ImageView for Android

CircleImageView A fast circular ImageView perfect for profile images. This is based on RoundedImageView from Vince Mi which itself is based on techniq

Henning Dodenhof 13.8k Mar 29, 2021