c# - Drawing a point over an ImageView in Android (using Xamarin) -


i building android app using xamarin , need able place points on map. said map image displayed using imageview (adding xml directly). tried making bitmap , canvas , displays black square red point (as wanted), actual map disappears. code:

[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 image bitmap canvas         canvas.drawbitmap(bitmap, 5, 5, paint);          //draw want canvas         canvas.drawcircle(50, 50, 10, paint);          //attach canvas imageview         map.setimagedrawable((new bitmapdrawable(bitmap)));          button item = findviewbyid<button>(resource.id.button1); //declare item button         item.click += delegate         {             startactivity(typeof(item));         };     } } 

does know problem is?

i tried making bitmap , canvas , displays black square red point (as wanted), actual map disappears.

by map.setimagedrawable((new bitmapdrawable(bitmap))); replacing map created bitmap.

as quick fix, can set map image background of layout instead of source of imageview:

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     xmlns:tools="http://schemas.android.com/tools"     android:orientation="vertical"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="@drawable/yourmapimage"     tools:context="com.example.winffee.scrollviewdemo.mainactivity">     <imageview         android:id="@+id/imgmap"         android:layout_width="match_parent"         android:layout_height="wrap_content"/> </linearlayout> 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -