Reputation: 6527
Say I have created a linearlayout ( linLayBtn ) and added it to an already existing in the xml linearlayout ( linLayRow )...
linLayRow.addView(linLayBtn, linLayBtnPar);
And now I need to know the X and Y coordinates of the linLayBtn layout that I just added.
How would you do that?
Upvotes: 0
Views: 1880
Reputation: 15744
currentsdk < sdk 11
getLeft(), getTop()
currentsdk >= sdk 11
getX(), getY()
Upvotes: 0
Reputation: 7161
x = linLayBtn.getX();
y = linLayBtn.getY();
Just remember that calling this in the constructor gives back 0 because views have to be measured and laid out first.
Upvotes: 1