android - How to get the rectangular perimeter of a view -


i have view , need it's top , bottom location on screen. run following experiment: trying figure out hit rectangle does, run following experiment

int[] location = { 0, 0 }; myview.getlocationonscreen(location); rect outrect = new rect(); myview.gethitrect(outrect); 

then print , got

outrect.top = 18 outrect.bottom = 138 location[0] = 216 location[1] = 387 

i expecting outrect.top , location[1] same.

so, how top , bottom location of rectangular view?

getlocationonscreen() returns x , y position of view relative screen: can calculate bottom position adding value of getheight() y position. gethitrect() returns position of view relative parent, why you're getting different numbers.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

c++ - Clear the memory after returning a vector in a function -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -