This post is about how to set the color and transparency of a round corner background in a remoteview (widget) in android. The main objective here is to retain the round corner when changing the round corner.
This was posted originally in http://oceanuz.wordpress.com/2013/07/11/widget-remoteviews-round-corners-background-and-colors/ and duplicated here.
The solution was based on an answer in SO: http://stackoverflow.com/questions/10307015/rounded-corners-on-dynamicly-set-imageview-in-widget
1. First there's a shape drawable called rounded.xml that's applied to an imageview in remoteview layout to create a background with round corner.
2. The drawable is applied as src of an imageview. Note the linearlayout container at the outer layer.
Finding 1: This layout have a nasty effect of causing the widget display to get "cut off" while refreshing. Still thinking of a solution. Will insert an screenshot here when got chance.
3. Finally, build the RemoteViews and pass it to the updateAppWidget, use setColorFilter and setAlpha (or setImageAlpha for SDK 16 or above) to apply the background color and transparency set by user.
No comments:
Post a Comment