Looking for an elegant appwidget skin solution
Posted
by sam-henwood
on Stack Overflow
See other posts from Stack Overflow
or by sam-henwood
Published on 2010-02-12T01:54:30Z
Indexed on
2010/04/18
5:13 UTC
Read the original article
Hit count: 510
I have an appwidget application and would like to enable users to create skins which can be applied at runtime. My preferred solution is to use apk files with nine patch png images that stretch to fit the ImageView's of widget, however its starting to look like I might have to use another packaging technique (e.g. zip files).
What I've tried: Importing nine patch resources as Drawable with context.getResourcesForApplication(my.app).getResources..., converting them to bitmaps using a canvas and setting the bitmap to the RemoteView using setImageViewBitap. This didn't work because I needed to specify the size of the resulting view (myBitmap.setBounds(..,..)) during conversion and some of the widths/heights in my appwidget aren't fixed. Perhaps there is a way to get the heights etc that I missed.
Importing resources directly to the RemoteView using setImageViewUri() This doesn't work because the function doesn't seem to read android.resource:// Uri's anymore (I poked around in the ImageView source and it only seems to read files paths and content:// Uri's)
Importing resources directly to the RemoteView using setImageViewResource() which didn't work because the id retrieved from the external package obviously doesn't include a package reference.
What I'm trying to avoid is hard coding all my appwidget width's and height's, or using a separate packaging scheme.
Has anyone implemented appwidget skins nicely and want to share the knowledge? Alternately there might be a hole in my logic somewhere that can be pointed out.
I can provide code if required though I don't have any here right now.
© Stack Overflow or respective owner