我正在尝试在小部件上绘制画布,但我什么都没有。我有一个带有imageviev的表格,它的位图,我会在里面画出所有的美,但是它没有画出来……这是我的一段代码,它不能用什么?
我画的供应商
public class MainActivity extends AppWidgetProvider {
private Bitmap bmp;
private RemoteViews views;
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
views = new RemoteViews(context.getApplicationContext().getPackageName(), R.layout.main);
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.RED);
paint.setTextSize(16);
paint.setAntiAlias(true);
paint.setTypeface(Typeface.MONOSPACE);
Bitmap bmp = Bitmap.createBitmap(100, 16, Bitmap.Config.ALPHA_8);
Canvas c = new Canvas(bmp);
c.drawText("fdgfdgfdgfdfdfdgGFDFGFDDDDG", 0, 0, paint);
views.setImageViewBitmap(R.id.imageView1, bmp);
}
}
和我的 main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dip"
android:background="@drawable/ic_launcher" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ImageView>