diff --git a/library/src/main/java/com/jmedeisis/draglinearlayout/DragLinearLayout.java b/library/src/main/java/com/jmedeisis/draglinearlayout/DragLinearLayout.java
index 168b32f..25b7ba1 100644
--- a/library/src/main/java/com/jmedeisis/draglinearlayout/DragLinearLayout.java
+++ b/library/src/main/java/com/jmedeisis/draglinearlayout/DragLinearLayout.java
@@ -176,14 +176,10 @@ public void stopDetecting() {
private int activePointerId = INVALID_POINTER_ID;
/**
- * The shadow to be drawn above the {@link #draggedItem}.
+ * The shadow to be drawn behind the {@link #draggedItem}.
*/
- private final Drawable dragTopShadowDrawable;
- /**
- * The shadow to be drawn below the {@link #draggedItem}.
- */
- private final Drawable dragBottomShadowDrawable;
- private final int dragShadowHeight;
+ private final Drawable dragShadowDrawable;
+ private final int dragShadowMargin;
/**
* See {@link #setContainerScrollView(android.widget.ScrollView)}.
@@ -209,9 +205,8 @@ public DragLinearLayout(Context context, AttributeSet attrs) {
slop = vc.getScaledTouchSlop();
final Resources resources = getResources();
- dragTopShadowDrawable = ContextCompat.getDrawable(context, R.drawable.ab_solid_shadow_holo_flipped);
- dragBottomShadowDrawable = ContextCompat.getDrawable(context, R.drawable.ab_solid_shadow_holo);
- dragShadowHeight = resources.getDimensionPixelSize(R.dimen.downwards_drop_shadow_height);
+ dragShadowDrawable = ContextCompat.getDrawable(context, R.drawable.shadow_light);
+ dragShadowMargin = resources.getDimensionPixelSize(R.dimen.drop_shadow_margin);
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.DragLinearLayout, 0, 0);
try {
@@ -394,8 +389,7 @@ public void onAnimationUpdate(ValueAnimator animation) {
draggedItem.setTotalOffset(((Float) animation.getAnimatedValue()).intValue());
final int shadowAlpha = (int) ((1 - animation.getAnimatedFraction()) * 255);
- if (null != dragTopShadowDrawable) dragTopShadowDrawable.setAlpha(shadowAlpha);
- dragBottomShadowDrawable.setAlpha(shadowAlpha);
+ if (null != dragShadowDrawable) dragShadowDrawable.setAlpha(shadowAlpha);
invalidate();
}
});
@@ -414,8 +408,7 @@ public void onAnimationEnd(Animator animation) {
draggedItem.settleAnimation = null;
draggedItem.stopDetecting();
- if (null != dragTopShadowDrawable) dragTopShadowDrawable.setAlpha(255);
- dragBottomShadowDrawable.setAlpha(255);
+ if (null != dragShadowDrawable) dragShadowDrawable.setAlpha(255);
// restore layout transition
if (layoutTransition != null && getLayoutTransition() == null) {
@@ -586,21 +579,16 @@ protected void dispatchDraw(@NonNull Canvas canvas) {
if (draggedItem.detecting && (draggedItem.dragging || draggedItem.settling())) {
canvas.save();
canvas.translate(0, draggedItem.totalDragOffset);
- draggedItem.viewDrawable.draw(canvas);
final int left = draggedItem.viewDrawable.getBounds().left;
final int right = draggedItem.viewDrawable.getBounds().right;
final int top = draggedItem.viewDrawable.getBounds().top;
final int bottom = draggedItem.viewDrawable.getBounds().bottom;
+ dragShadowDrawable.setBounds(left - dragShadowMargin, top - dragShadowMargin, right + dragShadowMargin, bottom + dragShadowMargin);
+ dragShadowDrawable.setAlpha(75);
+ dragShadowDrawable.draw(canvas);
- dragBottomShadowDrawable.setBounds(left, bottom, right, bottom + dragShadowHeight);
- dragBottomShadowDrawable.draw(canvas);
-
- if (null != dragTopShadowDrawable) {
- dragTopShadowDrawable.setBounds(left, top - dragShadowHeight, right, top);
- dragTopShadowDrawable.draw(canvas);
- }
-
+ draggedItem.viewDrawable.draw(canvas);
canvas.restore();
}
}
diff --git a/library/src/main/res/drawable-hdpi/ab_solid_shadow_holo.9.png b/library/src/main/res/drawable-hdpi/ab_solid_shadow_holo.9.png
deleted file mode 100644
index 2d59f35..0000000
Binary files a/library/src/main/res/drawable-hdpi/ab_solid_shadow_holo.9.png and /dev/null differ
diff --git a/library/src/main/res/drawable-mdpi/ab_solid_shadow_holo.9.png b/library/src/main/res/drawable-mdpi/ab_solid_shadow_holo.9.png
deleted file mode 100644
index ddfc8e3..0000000
Binary files a/library/src/main/res/drawable-mdpi/ab_solid_shadow_holo.9.png and /dev/null differ
diff --git a/library/src/main/res/drawable-xhdpi/ab_solid_shadow_holo.9.png b/library/src/main/res/drawable-xhdpi/ab_solid_shadow_holo.9.png
deleted file mode 100644
index d0df29d..0000000
Binary files a/library/src/main/res/drawable-xhdpi/ab_solid_shadow_holo.9.png and /dev/null differ
diff --git a/library/src/main/res/drawable-xxhdpi/ab_solid_shadow_holo.9.png b/library/src/main/res/drawable-xxhdpi/ab_solid_shadow_holo.9.png
deleted file mode 100644
index 8071886..0000000
Binary files a/library/src/main/res/drawable-xxhdpi/ab_solid_shadow_holo.9.png and /dev/null differ
diff --git a/library/src/main/res/drawable-xxhdpi/shadow_light.9.png b/library/src/main/res/drawable-xxhdpi/shadow_light.9.png
new file mode 100644
index 0000000..95b9e49
Binary files /dev/null and b/library/src/main/res/drawable-xxhdpi/shadow_light.9.png differ
diff --git a/library/src/main/res/drawable/ab_solid_shadow_holo_flipped.xml b/library/src/main/res/drawable/ab_solid_shadow_holo_flipped.xml
deleted file mode 100644
index 87be4a3..0000000
--- a/library/src/main/res/drawable/ab_solid_shadow_holo_flipped.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/values/dimens.xml b/library/src/main/res/values/dimens.xml
index ecb3ceb..300d8bd 100644
--- a/library/src/main/res/values/dimens.xml
+++ b/library/src/main/res/values/dimens.xml
@@ -1,4 +1,4 @@
- 16dp
+ 12dp
\ No newline at end of file
diff --git a/sample/src/main/res/layout/activity_demo.xml b/sample/src/main/res/layout/activity_demo.xml
index 9eb7908..98a38fc 100644
--- a/sample/src/main/res/layout/activity_demo.xml
+++ b/sample/src/main/res/layout/activity_demo.xml
@@ -17,6 +17,7 @@
android:text="@string/list_item_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_margin="8dp"
style="@style/SpaciousListItem" />
DragLinearLayout Demo
Simple linear layout
- Drag me! Drop me!
+ Drag me! Drop me! I have a margin.
Swap with me! Swap with me!
I\'m quite sensitive\nabout my height.
I heard that one of us is a Button!