getRight, getLeft, getTop returning zero

android

Solution

in `onResume` its too early to call getLeft, getRight ... Do it in `onWindowFocusChanged`

@Override
public void onWindowFocusChanged (boolean hasFocus){
    super.onWindowFocusChanged(hasFocus);
    if(hasFocus){
        System.out.println("onWindowFocusChanged"); 
        System.out.println("tab1 - left" + btn_Tab7 .getLeft());
        System.out.println("tab1 - Top" + btn_Tab7.getTop());
        System.out.println("tab1 - right" + btn_Tab7.getRight());
        System.out.println("tab1 - bottom" + btn_Tab7.getBottom());
    }
}

Documentation from onResume:

Keep in mind that onResume is not the best indicator that your activity is visible to the user; a system window such as the keyguard may be in front. Use onWindowFocusChanged(boolean) to know for certain that your activity is visible to the user (for example, to resume a game).

Problem

I am using following code. But all methods are returning zero value. I know that to get the coordinates of the view our view should be drawn. That why i am using the code in onResume method but still not working. Any Idea? ``` @Override public void onResume(){ super.onResume(); System.out.println("Onresume"); System.out.println("tab1 - left" + btn_Tab7 .getLeft()); System.out.println("tab1 - Top" + btn_Tab7.getTop()); System.out.println("tab1 - right" + btn_Tab7.getRight()); System.out.println("tab1 - bottom" + btn_Tab7.getBottom()); } ```

Original source