import android.graphics.Rect;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
LinearLayout line1, line2;

TextView txtView;

Rect m_Rect;

Integer x1,x2,y1,y2;

int[] arr = new int[2];

String result;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

line1 = (LinearLayout)findViewById(R.id.line1);
line2 = (LinearLayout)findViewById(R.id.line2);

txtView = (TextView) findViewById(R.id.txtView);

line1.getLocationOnScreen(arr);

result = " "+arr[0]+" "+arr[1]+" ";

line2.getLocationOnScreen(arr);

result += " "+arr[0]+" "+arr[1]+" ";

txtView.setText(result);
}
}
제가 위의 코드처럼 레이아웃 좌표를 구하려고 getLocationOnScreen()을 썼습니다.
레이아웃 모양은 

  

 

 

대충 이런모양이고 밑의 두칸이 line1, line2 입니다.
그런데 결과가 0 0 0 0 이에요...
제가 생각했던 결과는 대충 처음부터 끝이 0~10이라고 친다면, 중간점을 기준으로 해서
2.5 7.5 7.5 7.5 (물론 Integer라서 소숫점이 나올리는 없지만..) 정도로 나올줄 알았어요.
line1의 x좌표 y좌표 line2도 같은 방식으로 저렇게 나올줄 알았는데 그냥 0으로 나오더라구요..
이 메서드로는 안돼나 싶어서 getLocationInWindow()도 써보고 Rect 객체로
line2.getGlobalVisibleRect(m_Rect);
x1 = m_Rect.left;
x2 = m_Rect.top;
y1 = m_Rect.right;
y2 = m_Rect.bottom;
이렇게도 해봤는데 출력결과는 하나같이 다 0입니다.
뭐가 문제일까요..? ㅠㅠ
사실 메서드들의 기능도 완전히 이해하고있지 못합니다.. 왜 값이 출력이 안돼죠..?
제발 부탁드립니다.. 제가 출력하고 싶은 좌표값을 뽑아내려면 어떻게 해야할까요..?
복잡해도 상관없습니다.. 부탁드립니다..