I'm creating a widget where I need to rotate an ImageView. The ImageView resides insides a layout which in turn is described in a RemoteView. Is this possible? In my regular application Activity gained a reference to the ImageView using findViewById() and then calling setRotate(), but as RemoteView isn't an activity findViewById() isn't available.
I can see that it has been done before in this app: https://market.android.com/details?id=com.lanteanstudio.compass
If you are using RemoteViews
, then you cannot directly change the visible View itself, as there is no way of getting a reference to it -- a RemoteViews
object generally runs in a different process (in the case of the widgets on the Homescreen this is true - the widgets run in the Homescreen process, not your own).
Instead you need to create a new RemoteViews with the image rotated - you need to rotate the bitmap before setting it to the ImageView
.
Then get an instance of AppWidgetManager
, and call manager.updateAppWidget(appWidgetId, remoteView)
.