I have a situation where so far I have not been able to find an answer. I'm working on an app that uses a PopupWindow
in two different fragments. Each of the two fragments uses two popupwindows. So there are 4 popupwindows total. There is one view that is used for all the popupwindows. That view has an up pointing arrow that needs to point at the button that was clicked to open the popupwindow, no matter where the button may be. I have tried some different combinations of getLocationOnScreen()
, getX()
, getLeft()
, setX()
and setY()
. It is my understanding that getLocationInWindow()
is the only one that deals with the location of a view based on the devices screen size. The other 4 all get and set values based on the view's parent. Since the button that was clicked to open the popupwindow and the view used to show the contents in the popupwindow have different parents, getX(),
getLeft(),
setX()and
setY()` have resulted in setting the arrow's location at a different position for each button.
What I need, but have yet to find, is a way to set the position arrow image in the popupwindow based on the x and y coordinates I get from getLocationOnScreen()
. But there is no setLocationOnScreen()
.
So I need a way to calculate the arrow's position so that it sets under the button clicked, no matter where the button is or what the button's parents are. I'm sure there is a way to calculate it, I'm just not sure how.
Can anyone please help me out with this?