I need to move an ImageView (or anything else, for that matter) around inside a RelativeLayout. Does any one know the proper way to do this?
RelativeLayout is a view group that displays child views in relative positions. The position of each view can be specified as relative to sibling elements (such as to the left-of or below another view) or in positions relative to the parent RelativeLayout area (such as aligned to the bottom, left or center).
LinearLayout is less used as compared to RelativeLayout. RelativeLayout is used more in applications. We can use LinearLayout inside RelativeLayout. We can also use RelativeLayout as a Child of LinearLayout.
relativelayout is deprecated now.
LinearLayout : is a ViewGroup that aligns all children in a single direction, vertically or horizontally. RelativeLayout : is a ViewGroup that displays child views in relative positions. AbsoluteLayout : allows us to specify the exact location of the child views and widgets.
Makesure ImageView's layout_height and layout_width is set to fill_parent. Then do:
To move a view, use Matrix. It is very handy.
Matrix matrix = new Matrix();
matrix.reset();
matrix.postTranslate(x, y);
imageview.setScaleType(ScaleType.MATRIX);
imageview.setImageMatrix(matrix);
this I found worked:
imageview.layout(l,t,r,b);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With