1

I have implemented a custom ImageView that can be dragged around when housed in a RelativeLayout. Essnetially, I change the leftMargin and topMargin of the layout parameters as the view is being dragged.

This mostly works as expected. I can drag the view around. Even negative values for the margin work fine. The view can be dragged outside the left edge as well as the top edge.

The problem is I am not able to drag the view outside of right edge or the bottom edge. In fact, the view starts to shrink as I try to drag it outside any of these two edges.

I played with "clipChidren" as well as "clipToPadding" parameters on the RelativeLayout but that wasn't of any help.

I would appreciate it if someone can guide me on how to display a partial view at the right edge or the bottom edge. Thank you in advance for your help.

Zong
  • 6,160
  • 5
  • 32
  • 46
Peter
  • 11,260
  • 14
  • 78
  • 155

1 Answers1

1

This problem can be resolved if you change the rightMargin and bottomMargin as well when dragging. When you change all four margins, you will get the desired behaviour.

Amulya Khare
  • 7,718
  • 2
  • 23
  • 38
  • 2
    Thank you. That did the trick. For others interested, you just set the rightMargin and bottomMargin value to -250 (as suggested in a different post). – Peter Oct 25 '13 at 08:45
  • This logic works as long as your views is using fixed width and height. For any view that is resiable, this trick causes the view to suddenly magnify. Bummer. – Peter Oct 25 '13 at 12:34
  • http://stackoverflow.com/questions/9398057/android-move-a-view-on-touch-move-action-move is the post Peter might be referring to. – richy Jul 01 '15 at 08:37
  • Moving a child ImageView outside a parent RelaiveLayout though the bottom edge is causing the parent to move upwards in a similar way to when the soft keyboard appears, but there isn't any text view in the layout. – rraallvv Sep 24 '17 at 21:15