I need to get coordinates of some view inside my layout. I've try to do like (inside onCreateView)
TextView[] tv = new TextView[3]
tv[0] = (TextView) view.findViewById(R.id.content0);
tv[1] = (TextView) view.findViewById(R.id.content1);
tv[2] = (TextView) view.findViewById(R.id.content2);
RectF[] positions = new RectF[3];
for (int i = 0; i < tv.length; i++) {
int top = tv[i].getTop();
int left = tv[i].getLeft();
int width = tv[i].getWidth();
int height = tv[i].getHeight();
positions[i] = new RectF(left, top, left + width, top + height);
}
But if i try to print positions array into Logcat, i obtain always 0,0,0,0. What's wrong?