-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ability to change animation durations. indicator listener added. pager change listener added.
- Loading branch information
Showing
11 changed files
with
202 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.widget.RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".MainActivity"> | ||
|
||
<com.smarteist.autoimageslider.SliderView | ||
<androidx.cardview.widget.CardView | ||
android:layout_width="match_parent" | ||
android:layout_height="300dp" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentTop="true" | ||
android:id="@+id/imageSlider"/> | ||
android:layout_margin="16dp" | ||
app:cardCornerRadius="8dp"> | ||
|
||
|
||
<com.smarteist.autoimageslider.SliderView | ||
android:id="@+id/imageSlider" | ||
android:layout_width="match_parent" | ||
android:layout_height="300dp" /> | ||
</androidx.cardview.widget.CardView> | ||
|
||
</android.widget.RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
autoimageslider/src/main/java/com/smarteist/autoimageslider/SliderPager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.smarteist.autoimageslider; | ||
|
||
import android.content.Context; | ||
import android.util.AttributeSet; | ||
import android.view.animation.DecelerateInterpolator; | ||
import android.widget.Scroller; | ||
import androidx.viewpager.widget.ViewPager; | ||
import java.lang.reflect.Field; | ||
|
||
public class SliderPager extends ViewPager { | ||
|
||
public static final int DEFAULT_SCROLL_DURATION = 250; | ||
|
||
public SliderPager (Context context) { | ||
super(context); | ||
} | ||
|
||
public SliderPager (Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
} | ||
|
||
public void setScrollDuration(int millis) { | ||
try { | ||
Class<?> viewpager = ViewPager.class; | ||
Field scroller = viewpager.getDeclaredField("mScroller"); | ||
scroller.setAccessible(true); | ||
scroller.set(this, new OwnScroller(getContext(), millis)); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
class OwnScroller extends Scroller { | ||
|
||
private int durationScrollMillis; | ||
|
||
OwnScroller(Context context, int durationScroll) { | ||
super(context, new DecelerateInterpolator()); | ||
this.durationScrollMillis = durationScroll; | ||
} | ||
|
||
@Override | ||
public void startScroll(int startX, int startY, int dx, int dy, int duration) { | ||
super.startScroll(startX, startY, dx, dy, durationScrollMillis); | ||
} | ||
} | ||
} |
Oops, something went wrong.