Saturday, 10 April 2021

android .getTop() returns 0.0

I am developing an android lock screen app. I got the idea from another thread to check the coordinates of where the finger has pressed down against to the coordinates of the imagebutton that I have set up.

I am trying to get the coordinates of the imagebutton using the .getTop() and .getLeft() but both are returning 0.0 (as they are floats, not int).

why is this? I am new to android development, so sorry if I am missing something obvious.

Also, I read somewhere that the .getTop() won't work after the setContentView(R.layout.layoutname) but if I put it above setContentView(...) then the app crashes.

Is there another way to get the coordinates of the imagebutton, or would it be better/easier to get the coordinates and bounds of the table cell ? How would I do that?

Thanks in advance :)



from android .getTop() returns 0.0

No comments:

Post a Comment