@@ -0,0 +1,8 @@
+package com.android.views.banner;
+
+/**
+ * Created by Sai on 15/11/13.
+ */
+public interface OnItemClickListener {
+ public void onItemClick(int position);
+}
@@ -0,0 +1,49 @@ |
||
| 1 |
+package com.android.views.banner; |
|
| 2 |
+ |
|
| 3 |
+import android.content.Context; |
|
| 4 |
+import android.view.animation.Interpolator; |
|
| 5 |
+import android.widget.Scroller; |
|
| 6 |
+ |
|
| 7 |
+public class ViewPagerScroller extends Scroller {
|
|
| 8 |
+ private int mScrollDuration = 800;// 滑动速度,值越大滑动越慢,滑动太快会使3d效果不明显 |
|
| 9 |
+ private boolean zero; |
|
| 10 |
+ |
|
| 11 |
+ public ViewPagerScroller(Context context) {
|
|
| 12 |
+ super(context); |
|
| 13 |
+ } |
|
| 14 |
+ |
|
| 15 |
+ public ViewPagerScroller(Context context, Interpolator interpolator) {
|
|
| 16 |
+ super(context, interpolator); |
|
| 17 |
+ } |
|
| 18 |
+ |
|
| 19 |
+ public ViewPagerScroller(Context context, Interpolator interpolator, |
|
| 20 |
+ boolean flywheel) {
|
|
| 21 |
+ super(context, interpolator, flywheel); |
|
| 22 |
+ } |
|
| 23 |
+ |
|
| 24 |
+ @Override |
|
| 25 |
+ public void startScroll(int startX, int startY, int dx, int dy, int duration) {
|
|
| 26 |
+ super.startScroll(startX, startY, dx, dy, zero ? 0 : mScrollDuration); |
|
| 27 |
+ } |
|
| 28 |
+ |
|
| 29 |
+ @Override |
|
| 30 |
+ public void startScroll(int startX, int startY, int dx, int dy) {
|
|
| 31 |
+ super.startScroll(startX, startY, dx, dy, zero ? 0 : mScrollDuration); |
|
| 32 |
+ } |
|
| 33 |
+ |
|
| 34 |
+ public int getScrollDuration() {
|
|
| 35 |
+ return mScrollDuration; |
|
| 36 |
+ } |
|
| 37 |
+ |
|
| 38 |
+ public void setScrollDuration(int scrollDuration) {
|
|
| 39 |
+ this.mScrollDuration = scrollDuration; |
|
| 40 |
+ } |
|
| 41 |
+ |
|
| 42 |
+ public boolean isZero() {
|
|
| 43 |
+ return zero; |
|
| 44 |
+ } |
|
| 45 |
+ |
|
| 46 |
+ public void setZero(boolean zero) {
|
|
| 47 |
+ this.zero = zero; |
|
| 48 |
+ } |
|
| 49 |
+} |
@@ -0,0 +1,29 @@ |
||
| 1 |
+<?xml version="1.0" encoding="utf-8"?> |
|
| 2 |
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
| 3 |
+ android:layout_width="match_parent" |
|
| 4 |
+ android:layout_height="match_parent" |
|
| 5 |
+ android:orientation="vertical" > |
|
| 6 |
+ |
|
| 7 |
+ <RelativeLayout |
|
| 8 |
+ android:layout_width="match_parent" |
|
| 9 |
+ android:layout_height="match_parent" > |
|
| 10 |
+ |
|
| 11 |
+ <com.android.views.banner.CBLoopViewPager |
|
| 12 |
+ android:id="@+id/cbLoopViewPager" |
|
| 13 |
+ android:layout_width="match_parent" |
|
| 14 |
+ android:layout_height="match_parent" /> |
|
| 15 |
+ |
|
| 16 |
+ <!-- 翻页指示点的viewgroup --> |
|
| 17 |
+ |
|
| 18 |
+ <LinearLayout |
|
| 19 |
+ android:id="@+id/loPageTurningPoint" |
|
| 20 |
+ android:layout_width="wrap_content" |
|
| 21 |
+ android:layout_height="wrap_content" |
|
| 22 |
+ android:layout_alignParentBottom="true" |
|
| 23 |
+ android:layout_margin="10dp" |
|
| 24 |
+ android:layout_centerHorizontal="true" |
|
| 25 |
+ android:orientation="horizontal" > |
|
| 26 |
+ </LinearLayout> |
|
| 27 |
+ </RelativeLayout> |
|
| 28 |
+ |
|
| 29 |
+</LinearLayout> |
@@ -73,4 +73,7 @@ |
||
| 73 | 73 |
</attr> |
| 74 | 74 |
</declare-styleable> |
| 75 | 75 |
|
| 76 |
+ <declare-styleable name="ConvenientBanner"> |
|
| 77 |
+ <attr name="canLoop" format="boolean" /> |
|
| 78 |
+ </declare-styleable> |
|
| 76 | 79 |
</resources> |
@@ -0,0 +1,4 @@ |
||
| 1 |
+<?xml version="1.0" encoding="utf-8"?> |
|
| 2 |
+<resources> |
|
| 3 |
+ <item name="cb_item_tag" type="id"></item> |
|
| 4 |
+</resources> |