I try to set an Image to an ImageView in my Widget, but instead of picture I got an empty screen
here's layout :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/stage"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
here 's code :
public class MyWidget extends AppWidgetProvider {
Bitmap bitmap;
Bitmap bckgrnd;
Bitmap over;
@Override
public void onEnabled(Context context) {
super.onEnabled(context);
RemoteViews widgetView = new RemoteViews(context.getPackageName(),
R.layout.widget);
bckgrnd=BitmapFactory.decodeResource(context.getResources(), R.drawable.backgrnd);
over=BitmapFactory.decodeResource(context.getResources(), R.drawable.human);
bitmap=bckgrnd.copy(Bitmap.Config.ARGB_8888, true);;
Canvas c=new Canvas(bitmap);
c.drawBitmap(over, 50, 50, new Paint());
widgetView.setImageViewBitmap(R.id.stage, bitmap);
Log.d("MyLog", "onEnabled");
}
......
}
So, I have a Log of "OnEnabled" in my LogCat which means that this code has been executed well, but ImageView remains empty. If I set any image in layout xml - it shows that image, which means xml set right, but code doesn't change this Image in ImageView.
I tried to do this in onUpdate() but it didn't work either. What can I do to change this Image in ImageView?