Skip to content

Commit c9a782a

Browse files
committed
Add setSwipeAlpha()
1 parent 21760a3 commit c9a782a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

fragmentation_swipeback/src/main/java/me/yokeyword/fragmentation/SwipeBackLayout.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.graphics.Canvas;
66
import android.graphics.Rect;
77
import android.graphics.drawable.Drawable;
8+
import android.support.annotation.FloatRange;
89
import android.support.annotation.IntDef;
910
import android.support.v4.app.Fragment;
1011
import android.support.v4.app.FragmentActivity;
@@ -102,6 +103,7 @@ public class SwipeBackLayout extends FrameLayout {
102103

103104
private int mContentLeft;
104105
private int mContentTop;
106+
private float mSwipeAlpha = 0.5f;
105107

106108
/**
107109
* The set of listeners to be sent events through.
@@ -141,13 +143,22 @@ public ViewDragHelper getViewDragHelper() {
141143
return mHelper;
142144
}
143145

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+
144155
/**
145156
* Set scroll threshold, we will close the activity, when scrollPercent over
146157
* this value
147158
*
148159
* @param threshold
149160
*/
150-
public void setScrollThresHold(float threshold) {
161+
public void setScrollThresHold(@FloatRange(from = 0.0f, to = 1.0f) float threshold) {
151162
if (threshold >= 1.0f || threshold <= 0) {
152163
throw new IllegalArgumentException("Threshold value should be between 0 and 1.0");
153164
}
@@ -282,7 +293,7 @@ private void drawShadow(Canvas canvas, View child) {
282293

283294
private void drawScrim(Canvas canvas, View child) {
284295
final int baseAlpha = (DEFAULT_SCRIM_COLOR & 0xff000000) >>> 24;
285-
final int alpha = (int) (baseAlpha * mScrimOpacity);
296+
final int alpha = (int) (baseAlpha * mScrimOpacity * mSwipeAlpha);
286297
final int color = alpha << 24;
287298

288299
if ((mCurrentSwipeOrientation & EDGE_LEFT) != 0) {

0 commit comments

Comments
 (0)