Here is simple example how to do this using RemoteViews.
//create a remote view from widget layout RemoteViews views = new RemoteViews(context.getApplicationContext().getPackageName(), R.layout.widget_layout); //create a bitmap bitmap = Bitmap.createBitmap(100, 100, Config.ARGB_8888); //create a canvas from existant bitmap that will be used for drawing Canvas canvas = new Canvas(bitmap);
Than we can use android canvas methods to draw all we want.
//create new paint Paint p = new Paint(); p.setAntiAlias(true); p.setColor(hands_color); p.setStyle(Paint.Style.STROKE); p.setStrokeWidth(2); //draw circle canvas.drawCircle(50, 50, 7, p); //set our bitmap to view views.setImageViewBitmap(R.id.imageView, bitmap);
Have a nice code!