I know this is too late, but it may help someone ...
import org.osmdroid.views.overlay.MyLocationOverlay;
import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.graphics.Canvas; import android.graphics.Matrix ; import android.hardware.Sensor; import android.os.BatteryManager; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import android.widget.RelativeLayout; public class RotatingRelativeLayout extends RelativeLayout { private Matrix mMatrix = new Matrix(); private float[] mTemp = new float[2]; private Context context; private static final float SQ2 = 1.414213562373095f; public RotatingRelativeLayout(final Context pContext, final AttributeSet pAttrs) { super(pContext, pAttrs); this.context=pContext; } @Override protected void dispatchDraw(Canvas canvas) { long rotateTime = MyLocationOverlay.getTimeOfMovement(); float overlayBearing = MyLocationOverlay.getBearing();
now just use this relative layout in your xml like this: -
<YourPackageName.RotatingRelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/rotating_layout" android:layout_marginBottom="40dip"/>
And add Map View Programatially as follows: -
// Find target container final RelativeLayout rl=(RelativeLayout)mParent.findViewById(R.id.rotating_layout); // Create rotator mRotator=new RotatingRelativeLayout(mParent, null); // Add map to the rotating layout // Add rotator to the screen rl.addView(mMap,new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
here mParent is the context. And one more thing, if you come across Image Pixelation prob, you just have to use it
//Paint distortion handling.. p.setFilterBitmap(true);
Hopefully I explained it as best I could .... feel free to ask if you have found a problem understanding this.
Thanks.
source share