androidbitmapimageviewremoteview

Get Size of ImageView in RemoteViews


I am writing an Android AppWidget. The layout for the widget contains a LinearLayout and, inside that, a number of ImageViews. In the AppWidgetProvider OnUpdate method, I first create a RemoteViews for the layout ...

var rv = new RemoteViews(context.PackageName, Resource.Layout.WidgetLayout);

... and, using that, I can set the bitmaps for each of the child ImageViews.

However, what I really want to do is to get the actual size of the ImageViews once layout is complete so that I can draw exactly sized images (probably via Bitmaps) into them. I see no way to get the ImageView sizes via RemoteViews, nor any way to get to the underlying ImageView of a RemoteViews item.

Can I even do this? Is it done in OnUpdate()? If so, how? If not, where should I be doing it?

Thanks in advance.


Solution

  • Can I even do this?

    No. The rendering of the UI defined by the RemoteViews is handled by a separate app (home screen) in a separate process. You have no means of getting at Java objects from other processes, Views in particular.