At this stage your views aren't measured yet, that's why getWidth/getHeight
is always 0.

Try ImageView.getViewTreeObserver and register a PreDrawListener there you
can call getWidth/getHeight and get the real values.



On Thu, May 10, 2012 at 11:44 AM, Lamihck <[email protected]> wrote:

> Hello,
>
> I would like to find the size of a imageView from the start of my
> application.
>
> The idea is simple, I would do the same thing as Google Maps, ie
> display an image, and place pointers to places on this image.
>
> Pointers are recovered through the XML files containing X% and Y% in
> relation to the image.
>
> To place them on my image, I would do something like this:
>
> public void onCreate (Bundle savedInstanceState) {
>                super.onCreate (savedInstanceState);
>                {.... some code ....}
>                float maxX = imageViewCarte.getWidth();
>                float maxY = imageViewCarte.getHeight();
>
> The problem is that these values are null (0) at this stage of the
> application.
>
> So I tried to do the same onStart and the onResume, but to no avail, I
> get always 0!
>
> Yet if I do the same thing in an event like onClick to display the
> value in a toast, it is displayed correctly.
>
> I look forward to your response,
> Thank you for reading,
> Julien.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to