What's the proper way to implement an Android widget with dynamically drawn content? -
For my first and most awesomest Android project, I want to create a Home screen widget, which displays one of those That all children are crazy about these days. Based on the boundaries of
, I'm guessing that the proper way to actually draw on the screen is to use it in the actual layout, then when it is updating, make one or two and make them one Then draw the bitmap as the source of the image view, then draw on the newly created.
There is something about the process that I am not yet reading, however, the following code I have tried to use to update the widget. I do not get anything pulled on the screen. ImageView has a placeholder image that is set by its src
property when I do not run the code to update it in my drawing, the placeholder image remains in place so I know that This code is doing something , just clearly is not right is not a matter.
Remote Views View = New Remote Power (context.getPackageName (), R.Let.Widet); Bitmap bitmap = bitmap.creditbetaMap (100, 100, Configuration. ARGB_8888); Canvas canvas = new canvas (bitmap); Size dressable dragon = new size dracules (new arcshap (0, 360)); Drawable.getPaint () setColor (0xffff0000). Drawable.getPaint () setStrokeWidth (5.0f). Drawable.setIntrinsicWidth (100); Drawable.setIntrinsicHeight (100); Drawable.draw (canvas); Views.setImageViewBitmap (R.id.ImageView01, Bitmap); AppWidgetManager.updateAppWidget (Appevance ID, View);
I knew it could not be so easy, so am I going in the right direction too?
Update
OK, maybe this was too much information. The question I actually ask is:
If I want to draw shapes on a widget, should I use an image view and make a bitmap from the character of my size or in it Is there any proper measure to attract a widget where it is constrained by remote power?
In fact there is a widget called in SDK which is very similar to what you are trying to do.
It is implemented as a class that increases the view
and annotated with the @RemoteView
. It registers the receiver at Intent.ACTION_TIME_TICK
and Intent.ACTION_TIME_CHANGED
and pulls itself by overriding the onraw
method. Check it out. Check it out. Standard app as a widget that can be added to the home screen.
I think that this is a good (if not the best) way that you have described and it clearly works well.
Comments
Post a Comment