android - Custom ImageView doesn't display a Bitmap -


i'm making simple compass view that's displayed on top of mapview. layout mapview , other views declared in layout xml file.
i'm using this article example. i've written ondraw method compass view doesn't display anything. compass object gets invalidated in onsensorchanged method.
why isn't picture displayed?

xml layout

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/main_layout"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical" >      <com.mapviews.mycompass         android:id="@+id/compass"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentleft="true"         android:layout_alignparenttop="true"         android:layout_marginleft="20dp"         android:layout_margintop="20dp" />      <com.mapviews.transparentpanel         android:id="@+id/transparent_panel"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparenttop="true"         android:layout_centerhorizontal="true"         android:layout_margintop="3dp"         android:padding="5dp" />      <imagebutton         android:id="@+id/map_zoom_out"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentbottom="true"         android:layout_alignparentleft="true"         android:contentdescription="@string/cd_zoom_out"         android:src="@drawable/zoom_out" />      <imagebutton         android:id="@+id/map_zoom_in"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentbottom="true"         android:layout_torightof="@id/map_zoom_out"         android:contentdescription="@string/cd_zoom_in"         android:src="@drawable/zoom_in" />      <imagebutton         android:id="@+id/map_center_user"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentbottom="true"         android:layout_torightof="@id/map_zoom_in"         android:contentdescription="@string/cd_center_user"         android:src="@drawable/directions" />      <com.mapviews.mymap         android:id="@+id/mapview"         android:layout_width="fill_parent"         android:layout_height="fill_parent"         android:apikey="myapikey"         android:clickable="true"         android:state_enabled="true" /> 


part of mycompass class

@override     protected void ondraw(canvas canvas) {         super.ondraw(canvas);          canvas.drawcolor(color.transparent);          canvas.rotate(                 -1 * values.accelvalues[0]                 , values.width / 10                 , values.height / 10);          canvas.drawbitmap(                 bitmap                 , values.width / 10 - bitmap.getwidth() / 10                 , values.height / 10 - bitmap.getheight() / 10                 , paint);     }      public void setup(context c) {         paint = new paint();         bitmap = bitmapfactory.decoderesource(c.getresources(), r.drawable.compass1);     } 


in oncreate method

    compass = (mycompass) findviewbyid(r.id.compass);     compass.setup(this);     compass.bringtofront(); 


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -