Obtain the screen height and width
<p>I check the reference to obtain the Screen height and width. My mobile phone’s height and width like below</p>

<pre><code>Point p = new Point();
getWindowManager().getDefaultDisplay().getSize(p);
p.x //width 540
p.y //height 960
</code></pre>

<p>I write a demo, but the value obtained not right
The demo like this</p>

<pre><code>import android.graphics.Point;

public class Strike {
    private StrikeView view;
    private int left = 0;
    private int top = 0;
    private Point win;
    private boolean isDown = true;
    private boolean isRight = true;

    public Strike(StrikeView view, Point win) {
        this.view = view;
        this.win = win; 
        this.left = view.getLeft();
        this.top = view.getTop();
    }

    /**
     * Set direction and refresh
     */
    public void setPostion() {
        view.setLeft(left);
        view.setTop(top);
        view.invalidate();
    }

    /**
     * calculate view direction
     */
    public void postion() {
        if (isRight) {
            if (left + 30 &lt; win.x)
                left++;
            else {
                isRight = false;
                left--;
            }
        } else {
            if (left &gt; 0)
                left--;
            else {
                isRight = true;
                left++;
            }
        }
        if (isDown) {
            if (top + 30 &lt; win.y)
                top++;
            else {
                isDown = false;
                top--;
            }
        } else {
            if (top &gt; 0)
                top--;
            else {
                isDown = true;
                top++;
            }
        }

    }

}
</code></pre>
