There is no setBackground() method in the RemoteViews class, so I've used the following workaround:
- Created a 
FrameLayoutfor my app widget with anImageViewas the background view. - Changed the 
ImageViewimage usingsetImageViewResource()method. 
Unfortunately, when it comes to 9-patch drawables this method does not work. Also when an ImageView's android:src attribute points to 9-patch - it doesn't work too. Is there any way to change the AppWidget's background image programatically using a 9-patch drawable? Thanks in advance.
EDIT Settings the 9-patch as initial background in the XML:
<ImageView
    android:id="@+id/small_widget_layout_bg"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background_lime" />
When I use android:src="@drawable/background_lime" it doesn't stretch the image properly, this code works fine. And the code to change the background from the AppWidgetProvider onUpdate method:
views.setImageViewResource(R.id.small_widget_layout_bg,
                    R.drawable.backgroung_lime);
This does not stretch the image as a 9-patch.