0

Consider we have an imageView object like following:

 ImageView imageView ;
 textView = (TextView) findViewById(R.id.textView);

How can I move the imageView object in the favorite locations on the layout with programming and of course without changing the its height and width that I had configured in the relativeLayout.

and
  • 341
  • 1
  • 3
  • 11
  • Check this if it relates : http://stackoverflow.com/questions/30645531/move-imageview-inside-relativelayout-android/30645816#30645816 – Syed Nazar Muhammad Sep 07 '15 at 11:09
  • possible duplicate of [Move ImageView around inside RelativeLayout](http://stackoverflow.com/questions/1660150/move-imageview-around-inside-relativelayout) – Ashkan Sarlak Sep 07 '15 at 11:09

1 Answers1

0

For moving around a view inside a layout view, you could use margin layout properties such that margin_left and margin_top represent how much space should be at left and top of that view respectively from its original position.

If you would like your layout view does not restrict how its child view to be laid out, you would need FrameLayout. However some other layout views also would offer margin properties.

For example suppose we would like to move that ImageView by 2px in X direction. The code below, do this.

RelativeLayout.LayoutParams params = textview.getLayoutParams();
params.marginLeft = 2;
textview.requestLayout();
frogatto
  • 28,539
  • 11
  • 83
  • 129