An Android view for displaying repeated continuous side scrolling images. This can be used to create a parallax animation effect.

Overview

Scrolling Image View

An Android view for displaying repeated continuous side scrolling images. This can be used to create a parallax animation effect.

Example

Example

Installation

Step 1. Add the JitPack repository to your project build.gradle file

allprojects {
    repositories {
        // ~~~
        maven { url 'https://jitpack.io' }
    }
}

Step 2. Add the dependency in the form

dependencies {
    implementation 'com.github.Q42:AndroidScrollingImageView:1.3.4'
}

Sample app

Please see the sample app for some examples

Sample App

Usage

In your Android layout file add:

<com.q42.android.scrollingimageview.ScrollingImageView
    android:id="@+id/scrolling_background"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    scrolling_image_view:speed="60dp"
    scrolling_image_view:contiguous="false"
    scrolling_image_view:source="@drawable/scrolling_background" />

There are three attributes for the ScrollingImageView:

  • speed is the number of dp's to move the drawable per second (may be a negative number)

  • source is the drawable to paint. May refer to an array of drawables

  • contiguous When source is an array of drawables, contiguous determines their ordering.

    false (default) for random ordering, true for the same order as in the array

Don't forget to add the namespace to your root XML element

xmlns:scrolling_image_view="http://schemas.android.com/apk/res-auto"

In your Java code, you can start and stop the animation like this:

ScrollingImageView scrollingBackground = (ScrollingImageView) loader.findViewById(R.id.scrolling_background);
scrollingBackground.stop();
scrollingBackground.start();

Parallax effect

In order to achieve a parallax effect, you can stack multiple ScrollingImageView's in a FrameLayout with different speeds. For example:

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

  <com.q42.android.scrollingimageview.ScrollingImageView
      android:id="@+id/scrolling_background"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      scrolling_image_view:speed="60dp"
      scrolling_image_view:source="@drawable/scrolling_background" />
      
  <com.q42.android.scrollingimageview.ScrollingImageView
      android:id="@+id/scrolling_foreground"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      scrolling_image_view:speed="150dp"
      scrolling_image_view:source="@drawable/scrolling_foreground" />
</FrameLayout>
Comments
  • gradle failed

    gradle failed

    Error:Execution failed for task ':app:processDebugManifest'.

    Manifest merger failed : uses-sdk:minSdkVersion 14 cannot be smaller than version 16 declared in library [com.github.Q42:AndroidScrollingImageView:1.1] /home/om/AndroidStudioProjects/GoRide/app/build/intermediates/exploded-aar/com.github.Q42/AndroidScrollingImageView/1.1/AndroidManifest.xml Suggestion: use tools:overrideLibrary="com.q42.android.scrollingimageview" to force usage

    opened by shanmmukha1589 4
  • Getting null pointer exception

    Getting null pointer exception

    Caused by: java.lang.NullPointerException: Attempt to read from field 'int android.util.TypedValue.type' on a null object reference at com.q42.android.scrollingimageview.ScrollingImageView.(ScrollingImageView.java:57)

    opened by xardox69 2
  • Failed to resolve: com.github.Q42:AndroidScrollingImageView:1.1

    Failed to resolve: com.github.Q42:AndroidScrollingImageView:1.1

    Error:(20, 13) Failed to resolve: com.github.Q42:AndroidScrollingImageView:1.1 It says this, what is wrong? I put it in the app build.gradle not in the top-level build gradle. Is this the bug? It should not.

    opened by JonathanImperato 2
  • How to use in Android Studio

    How to use in Android Studio

    Step 1. Add the JitPack repository to your build file

    repositories { // ... maven { url "https://jitpack.io" } } Step 2. Add the dependency in the form

    dependencies { compile 'com.github.Q42:AndroidScrollingImageView:1.0' }

    I can not understand how to use

    opened by xingag 2
  • Feature/vector and framerate independence

    Feature/vector and framerate independence

    This change adds

    • vector support
    • Framerate independence
    • contiguous attribute. When true, slices are stitched in order. When false, slices are stitched in random order default: false

    For vector support, minSdk is increased to 21

    Existing users should know that the unit of speed has changed from dp per frame to dp per second. Therefore, migration entails multiplying all speeds by 60.

    opened by ninovanhooff 1
  • Failed to resolve.

    Failed to resolve.

    ive added the implementation 'com.github.Q42:AndroidScrollingImageView:1.3.2' line in dependencies in build.gradle ( Module: app ). im getting this error

    opened by facinick 1
  • The following classes could not be instantiated

    The following classes could not be instantiated

    While editing my layout in Android Studio 2.2 Build #AI-145.3276617 I get this error right after including ScrollingImageView

    The following classes could not be instantiated
    
    java.lang.NullPointerException
    	at com.q42.android.scrollingimageview.ScrollingImageView.<init>(ScrollingImageView.java:47)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    	at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:465)
    	at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:172)
    	at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
    	at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:186)
    	at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:334)
    	at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:345)
    	at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:245)
    	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
    	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
    	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
    	at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
    	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
    	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:861)
    	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
    	at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
    	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
    	at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
    	at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
    	at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:324)
    	at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
    	at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:389)
    	at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:548)
    	at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:533)
    	at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:966)
    	at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:533)
    	at com.android.tools.idea.rendering.RenderTask.lambda$inflate$72(RenderTask.java:659)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    	at java.lang.Thread.run(Thread.java:745)
    

    As of now I'm trying to debug the problem by myself but it seems I can't get a solution. But if I get one I'll post here

    opened by gerpanobanano 1
  • Error inflating class scrollingimageview Android 4.0.4

    Error inflating class scrollingimageview Android 4.0.4

    11-16 13:26:05.080: E/AndroidRuntime(3447): java.lang.RuntimeException: Unable to start activity ComponentInfo{scrollingimageview.android.q42.com.sampleapp/scrollingimageview.android.q42.com.sampleapp.MainActivity}: android.view.InflateException: Binary XML file line #28: Error inflating class scrollingimageview.android.q42.com.sampleapp.ScrollingImageView

    opened by dibakarece 1
  • Error:(364) Attribute

    Error:(364) Attribute "src" has already been defined

    The library crashes when integrated along with SubsamplingScaleImageView Library. The gradle sync return the error. How do i solve it ?

    Error:(364) Attribute "src" has already been defined

    opened by hablema 0
  • Resize large images based on AndroidScrollingImageView height

    Resize large images based on AndroidScrollingImageView height

    I put an image with large dimensions in the AndroidScrollingImageView,and i want the height to match the container, but it enlarges and takes the image original size. How to fix this?

    opened by Morteza-Rastgoo 0
  • Android 7 crash version 1.2

    Android 7 crash version 1.2

     Caused by: java.lang.NullPointerException: Attempt to read from field 'int android.util.TypedValue.type' on a null object reference
            at com.q42.android.scrollingimageview.ScrollingImageView.<init>(ScrollingImageView.java:83)
            at java.lang.reflect.Constructor.newInstance0(Native Method) 
            at java.lang.reflect.Constructor.newInstance(Constructor.java:430) 
            at android.view.LayoutInflater.createView(LayoutInflater.java:645) 
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787) 
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) 
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:858) 
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:518) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:426) 
            at androidx.databinding.DataBindingUtil.inflate(DataBindingUtil.java:126) 
            at androidx.databinding.ViewDataBinding.inflateInternal(ViewDataBinding.java:1409) 
    
    Caused by: java.lang.OutOfMemoryError: Failed to allocate a 29160012 byte allocation with 4194304 free bytes and 24MB until OOM
            at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
            at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
            at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:620)
            at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:455)
            at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:478)
            at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:508)
            at com.q42.android.scrollingimageview.ScrollingImageView.<init>(ScrollingImageView.java:82)
            at java.lang.reflect.Constructor.newInstance0(Native Method) 
            at java.lang.reflect.Constructor.newInstance(Constructor.java:430) 
            at android.view.LayoutInflater.createView(LayoutInflater.java:645) 
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787) 
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) 
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:858) 
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) 
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:861) 
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) 
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:861) 
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:518) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:426) 
            at androidx.databinding.DataBindingUtil.inflate(DataBindingUtil.java:126) 
            at androidx.databinding.ViewDataBinding.inflateInternal(ViewDataBinding.java:1409) 
            at com.fwd.codigo.databinding.FragmentStartBinding.inflate(FragmentStartBinding.java:109) 
            at com.fwd.codigo.databinding.FragmentStartBinding.inflate(FragmentStartBinding.java:95) 
            at com.fwd.codigo.feature.onboarding.StartFragment.onCreateView(StartFragment.kt:70) 
            at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2950) 
            at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:515) 
            at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282) 
            at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2177) 
            at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2088) 
            at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1990) 
            at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:524) 
            at android.os.Handler.handleCallback(Handler.java:751) 
            at android.os.Handler.dispatchMessage(Handler.java:95) 
            at android.os.Looper.loop(Looper.java:154) 
            at android.app.ActivityThread.main(ActivityThread.java:6077) 
            at java.lang.reflect.Method.invoke(Native Method) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) 
    2022-07-21 12:16:19.716 13336-13402/com.fwd.codigo.dev E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008cdf
    2022-07-21 12:16:19.717 13336-13402/com.fwd.codigo.dev E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008824
    
    
    opened by vanzar-codigo 0
  • How to scroll perfectly diagonally??

    How to scroll perfectly diagonally??

    while (offset <= -getBitmap(arrayIndex).getHeight()) { offset += getBitmap(arrayIndex).getHeight(); arrayIndex = (arrayIndex + 1) % scene.length; }

            float start = offset;
            for (int i = 0; start < clipBounds.height(); i++) {
                Bitmap bitmap = getBitmap((arrayIndex + i) % scene.length);
                int width = bitmap.getWidth();
                int height = bitmap.getHeight();
                canvas.drawBitmap(bitmap, getBitmapLeft(width, start), getBitmapTop(height, start), null);
                start += width;
            }
    
            if (isStarted && speed != 0) {
                offset -= abs(speed);
                postInvalidateOnAnimation();
            }
    
    opened by ghost 0
  • Does not save the current state while scrolling instead stores previous state of image for specific type of scroll

    Does not save the current state while scrolling instead stores previous state of image for specific type of scroll

    Hi, I was providing buttons to scroll image left or right. On click I set the speed and started the scrolling in selected direction for certain amount of time(used thread for this). Then when i scroll the image to other direction then it starts scrolling from image's start, actually it should scroll to other direction from the current position shown on UI.

    opened by ChinmayKalyankar 0
  • Failed to resolve: com.github.Q42:AndroidScrollingImageView:1.3.3

    Failed to resolve: com.github.Q42:AndroidScrollingImageView:1.3.3

    under project model (build.gradle) repositories { google() jcenter() maven { url 'https://jitpack.io' } }

    under app model (build.gradle) dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation 'com.github.Q42:AndroidScrollingImageView:1.3.3' }

    opened by chao9267 2
  • Failed to resolve: com.github.Q42:AndroidScrollingImageView:1.3.2 error

    Failed to resolve: com.github.Q42:AndroidScrollingImageView:1.3.2 error

    I'm using android studio 3.1.2, my app gradle is given below:

    apply plugin: 'com.android.application' android { compileSdkVersion 27 defaultConfig { applicationId "com.ajay.pocketassistance" minSdkVersion 21 targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support.constraint:constraint-layout:1.1.0' implementation 'com.android.support:support-v4:27.1.1' implementation 'com.android.support:design:27.1.1' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation 'com.jakewharton:butterknife:8.5.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' implementation 'com.andkulikov:transitionseverywhere:1.7.4' implementation 'com.github.bumptech.glide:glide:4.7.1' implementation 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.1.0' implementation 'com.github.Q42:AndroidScrollingImageView:1.3.2' }

    Is it a bug?

    opened by akulkarni9 1
Owner
Q42
A happy place for nerds
Q42
An image loading and caching library for Android focused on smooth scrolling

Glide | View Glide's documentation | 简体中文文档 | Report an issue with Glide Glide is a fast and efficient open source media management and image loading

Bump Technologies 33.2k Jan 7, 2023
🍂 Jetpack Compose image loading library which can fetch and display network images using Glide, Coil, and Fresco.

?? Jetpack Compose image loading library which can fetch and display network images using Glide, Coil, and Fresco.

Jaewoong Eum 1.4k Jan 2, 2023
An Android library for managing images and the memory they use.

Fresco Fresco is a powerful system for displaying images in Android applications. Fresco takes care of image loading and display, so you don't have to

Facebook 16.9k Jan 8, 2023
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 Dec 27, 2022
Media Picker is an Android Libary that lets you to select multiple images or video

Media Picker Please let me know if your application go to production via this link Media Picker is an Android Libary that lets you to select multiple

Abdullah Alhazmy 264 Nov 10, 2022
Andorid library that loads images asynchronously into cache using a thread pool

AndroidImageLoader AndroidImageLoader is a fork of the Image Loader component in libs-for-android. The AndroidImageLoader is an Android library that h

David Wu 63 Feb 19, 2019
Load images using Glide

Glide_Demo Load images using Glide Image used private val image = "https://cdn.pixabay.com/photo/2018/05/03/21/49/android-3372580_1280.png" Add Glide

Daniel Kago K 0 Nov 1, 2021
Splash - Wanted an app that displays images from Unsplash, well here it is

Splash - Wanted an app that displays images from Unsplash, well here it is

Bamidele Ajewole 2 Apr 26, 2022
load-the-image Apply to compose-jb(desktop), Used to load network and local pictures.

load-the-image load-the-image Apply to compose-jb(desktop), Used to load network and local pictures. ?? Under construction It may change incompatibly

lt_taozi 13 Dec 29, 2022
a solution that can help developers display pictures in any shape.

android-anyshape With the solution, pictures can be displayed in any shape on Android platform. Effect The left is the UI using normal ImageViews, and

Lankton 190 Dec 22, 2022
An imageView can auto scroll with device rotating.

PanoramaImageView An imageView can auto scroll with device rotating. ScreenShots Include PanoramaImageView to Your Project With gradle: dependencies {

郭佳哲 2.2k Dec 26, 2022
Composablee function for simulate a 360º photo view

?? What's up! ??‍?? Bugs360 ?? ?? Simulating a 360º view ?? ?? With this you can work with pack of photos, simulating a 360º view ?? ?? Made in ?? ??

Sito Nimbus 1 Nov 23, 2021
Easy to use, lightweight custom image view with rounded corners.

RoundedImageView Easy to use, lightweight custom image view with rounded corners. Explore the docs » View Demo · Report Bug · Request Feature About Th

Melik Mehmet Özyildirim 6 Dec 23, 2021
Android Asynchronous Networking and Image Loading

Android Asynchronous Networking and Image Loading Download Maven Git Features Kotlin coroutine/suspend support Asynchronously download: Images into Im

Koushik Dutta 6.3k Dec 27, 2022
A powerful image downloading and caching library for Android

Picasso A powerful image downloading and caching library for Android For more information please see the website Download Download the latest AAR from

Square 18.4k Jan 6, 2023
Image loading for Android backed by Kotlin Coroutines.

An image loading library for Android backed by Kotlin Coroutines. Coil is: Fast: Coil performs a number of optimizations including memory and disk cac

Coil 8.8k Jan 8, 2023
Adds touch functionality to Android ImageView.

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

Michael Ortiz 2.6k Jan 1, 2023
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 14.4k Jan 5, 2023
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

Siyamed SINIR 2.6k Jan 8, 2023