I have a view child which is added to a LinearLayout on my main Layout. I want to get the coordinates of this view on screen and I use getLocationOnWindow()
, getHeight()
, and getWidth()
methods but all the times I get 0. Finally I found the reason. Wherever I call these methods is during onCreate()
method. I mean, always I called before all layouts, view... etc. had been laid out. But I don't know When should I call?
Asked
Active
Viewed 688 times
0

derekerdmann
- 17,696
- 11
- 76
- 110

Sedat KURT
- 478
- 4
- 9
- 20
-
http://stackoverflow.com/questions/7776042/android-getting-the-width-of-a-button-which-is-set-to-wrap-content/7776052#7776052 – blessanm86 May 15 '12 at 11:45
1 Answers
0
No idea what you are saying but have you called setContentView(R.layout.my_layout)
before trying View myView = (View) findViewById(R.id.idofview)

user1378730
- 930
- 9
- 18