I have a widget with a config activity, where the user can select a color for the background of the widget from a color picker. I am using the method below where I have an ImageView and create a Bitmap which I dynamically set on the ImageView.
http://konsentia.com/2011/03/dynamically-changing-the-background-color-in-android-widgets/
public static Bitmap getBackground (int bgcolor)
{
try
{
Bitmap.Config config = Bitmap.Config.ARGB_8888; // Bitmap.Config.ARGB_8888 Bitmap.Config.ARGB_4444 to be used as these two config constant supports transparency
Bitmap bitmap = Bitmap.createBitmap(2, 2, config); // Create a Bitmap
Canvas canvas = new Canvas(bitmap); // Load the Bitmap to the Canvas
canvas.drawColor(bgcolor); //Set the color
return bitmap;
}
catch (Exception e)
{
return null;
}
}
Then
remoteViews.setImageViewBitmap(R.id.bgcolor, getBackground(bgcolor));
What I want to do though is let the user also choose if they want rounded corners on the widget. Is it possible to dynamically change both the color and whether the widget has rounded corners? From the examples I have looked at for rounding corners it seems you need to know the dimensions of the View so that you can round the edges before setting the Bitmap. I don't think this is possible from within a widget though... any ideas?