Skip to content Skip to sidebar Skip to footer

Create Dyanamic Rule

I am trying to dynamically resize an image which is in the relative layout using the code int height = v.getHeight(); int width = v.getWidth(); height += 50; width += 50; Relat

Solution 1:

What you are asking, can't be done simply by creating rules. You need to do the extra work for such alignment.

1) use addRule to align parent left & align parent top, then set the left and top margin to align the image to any position you want 100,100 or 200, 50 etc. after that you can resize the image without changing position.

2) if you keep the image aligned CENTER_IN_PARENT then the image resize is a bit typical. you need to increase the left and top padding according to the increased size to align the image in center.

suppose image size is 100x100 and new size is 150x150 now you need to set layout parameters to width x height to 200x200 and set the left and top padding of image to 50.

I hope its clear

Post a Comment for "Create Dyanamic Rule"