Added horizontal and vertical offset for swiping
This commit is contained in:
parent
f3b50c4e17
commit
dee951d85d
|
|
@ -3,9 +3,11 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<com.daimajia.swipe.SwipeLayout
|
||||
xmlns:swipe="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/swipe"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
swipe:horizontalSwipeOffset="25dp"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ public class SwipeLayout extends FrameLayout {
|
|||
private DragEdge mDragEdge;
|
||||
private ShowMode mShowMode;
|
||||
|
||||
private float horizontalSwipeOffset;
|
||||
private float verticalSwipeOffset;
|
||||
|
||||
private List<SwipeListener> mSwipeListeners = new ArrayList<SwipeListener>();
|
||||
private List<SwipeDenier> mSwipeDeniers = new ArrayList<SwipeDenier>();
|
||||
private Map<View, ArrayList<OnRevealListener>> mRevealListeners = new HashMap<View, ArrayList<OnRevealListener>>();
|
||||
|
|
@ -65,6 +68,8 @@ public class SwipeLayout extends FrameLayout {
|
|||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SwipeLayout);
|
||||
int ordinal = a.getInt(R.styleable.SwipeLayout_drag_edge, DragEdge.Right.ordinal());
|
||||
horizontalSwipeOffset =a.getDimension(R.styleable.SwipeLayout_horizontalSwipeOffset,0);
|
||||
verticalSwipeOffset =a.getDimension(R.styleable.SwipeLayout_verticalSwipeOffset,0);
|
||||
mDragEdge = DragEdge.values()[ordinal];
|
||||
ordinal = a.getInt(R.styleable.SwipeLayout_show_mode, ShowMode.PullOut.ordinal());
|
||||
mShowMode = ShowMode.values()[ordinal];
|
||||
|
|
@ -657,9 +662,9 @@ public class SwipeLayout extends FrameLayout {
|
|||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
if(mDragEdge == DragEdge.Left || mDragEdge == DragEdge.Right)
|
||||
mDragDistance = getBottomView().getMeasuredWidth();
|
||||
mDragDistance = getBottomView().getMeasuredWidth()-dp2px(horizontalSwipeOffset);
|
||||
else
|
||||
mDragDistance = getBottomView().getMeasuredHeight();
|
||||
mDragDistance = getBottomView().getMeasuredHeight()-dp2px(verticalSwipeOffset);
|
||||
}
|
||||
|
||||
private boolean mTouchConsumedByChild = false;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
<enum name="top" value="2"/>
|
||||
<enum name="bottom" value="3"/>
|
||||
</attr>
|
||||
<attr name="horizontalSwipeOffset" format="dimension"/>
|
||||
<attr name="verticalSwipeOffset" format="dimension"/>
|
||||
<attr name="show_mode" format="enum">
|
||||
<enum name="lay_down" value="0"/>
|
||||
<enum name="pull_out" value="1"/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue