getLocationOnScreen; View.getLocationInWindow(int[] location)

View.getLocationInWindow(int[] location)
一個控件在其父窗口中的座標位置
View.getLocationOnScreen(int[] location)
一個控件在其整個屏幕上的座標位置

start = (Button) findViewById(R.id.start);  
        int []location=new int[2];  
        start.getLocationOnScreen(location);  
        int x=location[0];//獲取當前位置的橫座標  
        int y=location[1];//獲取當前位置的縱座標  
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章