• This repository has been archived on 17/Jul/2023
  • Stars
    star
    359
  • Rank 118,537 (Top 3 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created about 8 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Endless scrolling background with drawable tiling

Scrolling Background View

Endless background scrolling for Android

Please note, that first GIF uses library: CCF to achive color-cross-fade effect, please refer to the sample project for more info.

Version Gradle
Maven Central compile 'ru.noties:sbv:x.x.x'

A simple Android View that can help to achive endless scrolling background effect. It takes one drawable and tiles it to fill to the width & height of the view.

<ru.noties.sbv.ScrollingBackgroundView
    android:id="@+id/scrolling_background_view"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:sbv_drawable="@drawable/tile_pager"
    app:sbv_scrollX="0dip"
    app:sbv_scrollY="0dip"/>

Custom attributes:

  • sbv_drawable - the drawable object to be used
  • sbv_scrollX - start scroll x value
  • sbv_scrollY - start scroll y value

This view works with preview layout tools in Android Studio.

Next we need to redirect scroll events from our scrolling View to the ScrollingBackgroundView. The sample project contains some basic cases like RecyclerView & ViewPager.

final ScrollingBackgroundView scrollingBackgroundView = findView(view, R.id.scrolling_background_view);

scrollingBackgroundView.setDrawable(/* drawable reference */);

scrollingBackgroundView.setOnSizeChangedListener(/* a listener to be notified about size changes of this view */);

// actual scrolling methods
scrollingBackgroundView.scrollBy(/* x & y values */);
scrollingBackgroundView.scrollTo(/* x & y values */);

scrollingBackgroundView.scrollX(); // use this method to retrieve current scroll x value
scrollingBackgroundView.scrollY(); // use this method to retrieve current scroll y value
final RecyclerView recyclerView = findView(view, R.id.recycler_view);
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
    @Override
    public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
        scrollingBackgroundView.scrollBy(dx, dy);
    }
});

License

  Copyright 2016 Dimitry Ivanov ([email protected])

  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.

More Repositories

1

Markwon

Android markdown library (no WebView)
Java
2,758
star
2

Scrollable

Android scrollable tabs
Java
1,237
star
3

FillDrawable

Java
108
star
4

Enhance

Add API information (since/deprecation) to Android source code as javadoc tags
Java
81
star
5

Debug

Android logging utility
Java
62
star
6

Storm

Android SQLite database manager
Java
53
star
7

Prism4j

Simplified Java clone of prism-js
Java
51
star
8

ColorCrossFade

Color cross fade utility for Android
Java
46
star
9

Flatten

Flatten json response with Flatten & Gson
Java
35
star
10

SharedPreferencesGenerator

Android annotation based SharedPreferences Generator
Java
30
star
11

ScriptJava

Java REPL today
Java
21
star
12

Handle

Handler-based Eventbus for Android
Java
18
star
13

SimplePrefs

Android SharedPreferences made easy
Java
14
star
14

ParcelGen

Android easy Parcelable
Java
7
star
15

BuildTimeGradleCodeGen

The most trivial (and hacky) code generation with Gradle for Android
7
star
16

Lifebus

Lifecycle events bus for Android
Java
7
star
17

Tumbleweed-Tutorial

Create complex Android animations with Tumblweed library
Java
7
star
18

Requirements

Small utility library for Android to evaluate requirements in order for some action to proceed. For example: network connection, permissions (API 23), system services (location, bluetooth, ...), etc.
Java
7
star
19

Adapt

RecyclerView.Adapter only shorter
Kotlin
5
star
20

Storm2.0

Java
4
star
21

DemoUi

Command line tool to access Android Demo Ui
Java
3
star
22

ViewTypes

Android adapter view types abstraction
Java
3
star
23

CursorMock

CursorMock for Android
Java
3
star
24

DrawableUtils

Java
3
star
25

Lazy

Utility to postpone initialisation of a value
Java
2
star
26

SqlBuilder

Utility to build SQL statement with binding of named arguments
Java
2
star
27

BlogProjects

https://noties.io
Kotlin
2
star
28

StopShip

A convenience utility around Android's STOPSHIP functionality with build-in Lint support
Kotlin
2
star
29

android-prettify

Java
2
star
30

RxTask

Java
1
star
31

IconView

One image resource for multiple colors
Java
1
star
32

GithubPackageRegistryAndroid

Playground for Github Package Registry Android artifacts built with Gradle
Java
1
star
33

NullSafe

Null safe flow for Java & Android
Java
1
star
34

todo

Java
1
star
35

Remodel

Java
1
star
36

Tasker

Java
1
star
37

Permissions

Android permissions
Java
1
star
38

Maqueta

Java
1
star
39

Listeners

Simple data structure with iteration and adding/removal of elements without copying of underlying collection
Java
1
star