Skip to content
This repository was archived by the owner on Feb 20, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 34 additions & 30 deletions Library/src/com/slidinglayer/SlidingLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1075,18 +1075,18 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
mScreenSide = screenSide;
closeLayer(false, true);

if (mScreenSide == STICK_TO_RIGHT) {
setPadding(getPaddingLeft() + mShadowWidth, getPaddingTop(), getPaddingRight(), getPaddingBottom());
} else if (mScreenSide == STICK_TO_BOTTOM) {
setPadding(getPaddingLeft(), getPaddingTop() + mShadowWidth, getPaddingRight(), getPaddingBottom());
} else if (mScreenSide == STICK_TO_LEFT) {
setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight() + mShadowWidth, getPaddingBottom());
} else if (mScreenSide == STICK_TO_TOP) {
setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(), getPaddingBottom() + mShadowWidth);
} else if (mScreenSide == STICK_TO_MIDDLE) {
setPadding(getPaddingLeft() + mShadowWidth, getPaddingTop(), getPaddingRight() + mShadowWidth,
getPaddingBottom());
}
// if (mScreenSide == STICK_TO_RIGHT) {
// setPadding(getPaddingLeft() + mShadowWidth, getPaddingTop(), getPaddingRight(), getPaddingBottom());
// } else if (mScreenSide == STICK_TO_BOTTOM) {
// setPadding(getPaddingLeft(), getPaddingTop() + mShadowWidth, getPaddingRight(), getPaddingBottom());
// } else if (mScreenSide == STICK_TO_LEFT) {
// setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight() + mShadowWidth, getPaddingBottom());
// } else if (mScreenSide == STICK_TO_TOP) {
// setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(), getPaddingBottom() + mShadowWidth);
// } else if (mScreenSide == STICK_TO_MIDDLE) {
// setPadding(getPaddingLeft() + mShadowWidth, getPaddingTop(), getPaddingRight() + mShadowWidth,
// getPaddingBottom());
// }
}

super.onLayout(changed, left, top, right, bottom);
Expand Down Expand Up @@ -1126,9 +1126,9 @@ private int getDestScrollX(int velocity) {
return 0;
} else {
if (mScreenSide == STICK_TO_RIGHT) {
return -getWidth() + mOffsetWidth;
return -getWidth() - mShadowWidth + mOffsetWidth;
} else if (mScreenSide == STICK_TO_LEFT) {
return getWidth() - mOffsetWidth;
return getWidth() + mShadowWidth - mOffsetWidth;
} else if (mScreenSide == STICK_TO_TOP || mScreenSide == STICK_TO_BOTTOM) {
return 0;
} else {
Expand All @@ -1154,9 +1154,9 @@ private int getDestScrollY(int velocity) {
return 0;
} else {
if (mScreenSide == STICK_TO_BOTTOM) {
return -getHeight() + mOffsetWidth;
return -getHeight() - mShadowWidth + mOffsetWidth;
} else if (mScreenSide == STICK_TO_TOP) {
return getHeight() - mOffsetWidth;
return getHeight() + mShadowWidth - mOffsetWidth;
} else if (mScreenSide == STICK_TO_LEFT || mScreenSide == STICK_TO_RIGHT) {
return 0;
} else {
Expand All @@ -1178,20 +1178,24 @@ protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
// Draw the margin drawable if needed.
if (mShadowWidth > 0 && mShadowDrawable != null) {
if (mScreenSide == STICK_TO_RIGHT) {
mShadowDrawable.setBounds(0, 0, mShadowWidth, getHeight());
}
if (mScreenSide == STICK_TO_TOP) {
mShadowDrawable.setBounds(0, getHeight() - mShadowWidth, getWidth(), getHeight());
}
if (mScreenSide == STICK_TO_LEFT) {
mShadowDrawable.setBounds(getWidth() - mShadowWidth, 0, getWidth(), getHeight());
}
if (mScreenSide == STICK_TO_BOTTOM) {
mShadowDrawable.setBounds(0, 0, getWidth(), mShadowWidth);
}
mShadowDrawable.draw(canvas);
}
if (mScreenSide == STICK_TO_RIGHT) {
mShadowDrawable.setBounds(getLeft() - mShadowWidth, 0,
getLeft(), getHeight());
}
if (mScreenSide == STICK_TO_TOP) {
mShadowDrawable.setBounds(0, getHeight(), getWidth(),
getHeight() + mShadowWidth);
}
if (mScreenSide == STICK_TO_LEFT) {
mShadowDrawable.setBounds(getWidth(), 0, getWidth()
+ mShadowWidth, getHeight());
}
if (mScreenSide == STICK_TO_BOTTOM) {
mShadowDrawable.setBounds(0, -mShadowWidth,
getWidth(), 0);
}
mShadowDrawable.draw(canvas);
}
}

@Override
Expand Down