What about
RelativeLayout mlayout = findViewById(R.id.yourID);
float x = mlayout.getX();
float y = mlayout.getY();
Edit: from Resizing layouts programmatically (as animation)
So you need the final height and width, maybe you can make it invisbile, change to WRAP_CONTENT, measure new heigth and width, change back, make visible and animate size with code above to new height and width.
Dont know a better way unfortunately.
Then animate width:
InstantiateResizeAnimation
ResizeAnimation resizeAnimation = new ResizeAnimation(
view,
targetHeight,
startHeight,
targetWidth,
startWidth
);
resizeAnimation.setDuration(duration);
view.startAnimation(resizeAnimation);
ResizeAnimation
class should look like this
public class ResizeAnimation extends Animation {
final int targetHeight;
final int targetWidth;
View view;
int startHeight;
int startWidth;
public ResizeAnimation(View view, int targetHeight, int startHeight, targetWidth, int startWidth) {
this.view = view;
this.targetHeight = targetHeight;
this.startHeight = startHeight;
this.targetWidth = targetWidth;
this.startWidth = startWidth;
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
int newHeight = (int) (startHeight + targetHeight * interpolatedTime);
int newWidth= (int) (startWidth + targetWidth * interpolatedTime);
view.getLayoutParams().height = newHeight;
view.getLayoutParams().width = newWidth;
view.requestLayout();
}
@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
super.initialize(width, height, parentWidth, parentHeight);
}
@Override
public boolean willChangeBounds() {
return true;
}
}