tags:

views:

38

answers:

1

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 onStart() in the application that contains the TextView.

Thanks for any hints!

RG

A: 

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

Asahi
Ah. I already tried onResume, but that's too early too.
Rene
So I have to subclass TextView somehow? I am currently finding the view by Id, and that gives me no chance to catch it's onMeasure method. I'll probably try to use the display width.
Rene
You can subclass layout itself and override onMeasure/onLayout - whatever suits you best
Asahi