0
私はXamarinを使用してAndroidアプリを構築しており、マップ上にいくつかのポイントを配置できる必要があります。このマップは、ImageViewを使用して表示された画像です(xmlから直接追加します)。 ビットマップとキャンバスを作ろうとしましたが、赤い点(必要に応じて)の黒い四角形が表示されますが、実際のマップは消えます。これは私のコードです:AndroidでImageView上にポイントを描画する(Xamarinを使用)
[Activity(Label = "Map")]
public class Map : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.Map);
ImageView map = FindViewById<ImageView>(Resource.Id.imageView1);
Bitmap bitmap = Bitmap.CreateBitmap(500, 500, Bitmap.Config.Rgb565);
Paint paint = new Paint();
paint.SetARGB(255, 255, 0, 0);
Canvas canvas = new Canvas(bitmap);
//Draw the image bitmap into the canvas
canvas.DrawBitmap(bitmap, 5, 5, paint);
//Draw everything you want into the canvas
canvas.DrawCircle(50, 50, 10, paint);
//Attach the canvas to the ImageView
map.SetImageDrawable((new BitmapDrawable(bitmap)));
Button item = FindViewById<Button>(Resource.Id.button1); //Declare item button
item.Click += delegate
{
StartActivity(typeof(Item));
};
}
}
問題は何ですか?