I tried to resize an image inside a textview (using HTML layout and the image callback), but I could not get the correct width of the view. getWidth() always returns 0 for this view. I am calling the function inside开发者_JAVA百科 onStart() in the application that contains the TextView.
Thanks for any hints!
RG
It is too early to call getWidth
in onStart
as the layout is not created yet. Try doing it in onMeasure
.
PS. You may want to post some of your code as the question is not completely clear
You could pop this in onSizeChanged or in onLayout, these are called after the views are created.
Edit: the links seem to break the formatting...
http://developer.android.com/reference/android/view/View.html#onSizeChanged(int, int, int, int)
http://developer.android.com/reference/android/view/View.html#onLayout(boolean, int, int, int, int)
精彩评论