ScrollZoomListView

A grace comic reader widget, expand ListView.

expand

1. scale item:

2. scale and translate total:

3. zoom total:

ScrollZoomListView use Animation and Canvas let ListView scale and translate, add ScaleGestureDetector , GestureDetector expand ListView.

Core code

1
2
3
4
5
6
7
8

@Override protected void dispatchDraw(@NonNull Canvas canvas) {
canvas.save(Canvas.MATRIX_SAVE_FLAG);
canvas.translate(mTranslateX, mTranslateY);
canvas.scale(mScaleFactor, mScaleFactor);
super.dispatchDraw(canvas);
canvas.restore();
}

Gradle

Add it in your root build.gradle at the end of repositories:

1
2
3
4
5
6
7

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

Add the dependency:

1
2
3
4

dependencies {
compile 'com.github.ruzhan123:ScollZoomListView:v1.0'
}

Usage

1
2
3
4
5
6
7
8
9
10
11
<zhan.scrollzoomlist.ScrollZoomListView
android:id="@+id/list"
app:min_zoom_scale="0.4"
app:max_zoom_scale="2.0"
app:zoom_scale_duration="300"
app:zoom_to_small_scale_duration="500"
app:zoom_to_small_times="6"
app:normal_scale="1.0"
app:zoom_scale="2.0"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

expand Interface

Synchronous ListView Animation:

1
2
3
4
5
6
7
8
9
10
11
12

public interface OnListViewZoomListener {

void onListViewZoomUpdate(ValueAnimator animation, float translateX, float translateY,
float scaleX, float scaleY)
;


void onListViewStart();

void onListViewCancel();
}

private List<OnListViewZoomListener> mOnListViewZoomListeners = new ArrayList<>();

Synchronous ListView ScaleGestureDetector:

1
2

private List<ScaleGestureDetector.SimpleOnScaleGestureListener> mOnScaleGestureListeners = new ArrayList<>();

Synchronous ListView GestureDetector:

1
2

private List<GestureDetector.SimpleOnGestureListener> mSimpleOnGestureListeners = new ArrayList<>();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

public void addOnScaleGestureListener(ScaleGestureDetector.SimpleOnScaleGestureListener listener) {
if(listener != null) {
if(!mOnScaleGestureListeners.contains(listener)) {
mOnScaleGestureListeners.add(listener);
}
}
}
public void removeOnScaleGestureListener(ScaleGestureDetector.SimpleOnScaleGestureListener listener) {
if(listener != null) {
if(mOnScaleGestureListeners.contains(listener)) {
mOnScaleGestureListeners.remove(listener);
}
}
}

License

Copyright 2017 ruzhan

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.
您的打赏是我继续前进的动力