Merge pull request #57 from rahulrj/master

Added horizontal and vertical offset for swiping
This commit is contained in:
代码家 2014-12-13 10:01:24 +08:00
commit 4d66856185
3 changed files with 11 additions and 2 deletions

View File

@ -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

View File

@ -30,6 +30,9 @@ public class SwipeLayout extends FrameLayout {
private DragEdge mDragEdge;
private ShowMode mShowMode;
private float mHorizontalSwipeOffset;
private float mVerticalSwipeOffset;
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());
mHorizontalSwipeOffset =a.getDimension(R.styleable.SwipeLayout_horizontalSwipeOffset,0);
mVerticalSwipeOffset =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(mHorizontalSwipeOffset);
else
mDragDistance = getBottomView().getMeasuredHeight();
mDragDistance = getBottomView().getMeasuredHeight()-dp2px(mVerticalSwipeOffset);
}
private boolean mTouchConsumedByChild = false;

View File

@ -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"/>