|
5 | 5 | import android.graphics.Canvas;
|
6 | 6 | import android.graphics.Rect;
|
7 | 7 | import android.graphics.drawable.Drawable;
|
| 8 | +import android.support.annotation.FloatRange; |
8 | 9 | import android.support.annotation.IntDef;
|
9 | 10 | import android.support.v4.app.Fragment;
|
10 | 11 | import android.support.v4.app.FragmentActivity;
|
@@ -102,6 +103,7 @@ public class SwipeBackLayout extends FrameLayout {
|
102 | 103 |
|
103 | 104 | private int mContentLeft;
|
104 | 105 | private int mContentTop;
|
| 106 | + private float mSwipeAlpha = 0.5f; |
105 | 107 |
|
106 | 108 | /**
|
107 | 109 | * The set of listeners to be sent events through.
|
@@ -141,13 +143,22 @@ public ViewDragHelper getViewDragHelper() {
|
141 | 143 | return mHelper;
|
142 | 144 | }
|
143 | 145 |
|
| 146 | + /** |
| 147 | + * 滑动中,上一个页面View的阴影透明度 |
| 148 | + * |
| 149 | + * @param alpha 0.0f:无阴影, 1.0f:较重的阴影, 默认:0.5f |
| 150 | + */ |
| 151 | + public void setSwipeAlpha(@FloatRange(from = 0.0f, to = 1.0f) float alpha) { |
| 152 | + this.mSwipeAlpha = alpha; |
| 153 | + } |
| 154 | + |
144 | 155 | /**
|
145 | 156 | * Set scroll threshold, we will close the activity, when scrollPercent over
|
146 | 157 | * this value
|
147 | 158 | *
|
148 | 159 | * @param threshold
|
149 | 160 | */
|
150 |
| - public void setScrollThresHold(float threshold) { |
| 161 | + public void setScrollThresHold(@FloatRange(from = 0.0f, to = 1.0f) float threshold) { |
151 | 162 | if (threshold >= 1.0f || threshold <= 0) {
|
152 | 163 | throw new IllegalArgumentException("Threshold value should be between 0 and 1.0");
|
153 | 164 | }
|
@@ -282,7 +293,7 @@ private void drawShadow(Canvas canvas, View child) {
|
282 | 293 |
|
283 | 294 | private void drawScrim(Canvas canvas, View child) {
|
284 | 295 | final int baseAlpha = (DEFAULT_SCRIM_COLOR & 0xff000000) >>> 24;
|
285 |
| - final int alpha = (int) (baseAlpha * mScrimOpacity); |
| 296 | + final int alpha = (int) (baseAlpha * mScrimOpacity * mSwipeAlpha); |
286 | 297 | final int color = alpha << 24;
|
287 | 298 |
|
288 | 299 | if ((mCurrentSwipeOrientation & EDGE_LEFT) != 0) {
|
|
0 commit comments