I don't seem to understand the difference much between getTop() and getY() in android Views. How are they different ?
getTop()
returns the y coordinate relative to the parent.
getY()
returns the y coordinate relative to the parent like getTop()
, plus the y translation as returned by getTranslationY()
.
For questions like this it's often helpful to consult the source:
public final int getTop() {
return mTop;
}
http://androidxref.com/5.1.0_r1/xref/frameworks/base/core/java/android/view/View.java#10644
public float getY() {
return mTop + getTranslationY();
}
http://androidxref.com/5.1.0_r1/xref/frameworks/base/core/java/android/view/View.java#10908
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