I'm sorry, I was totally wrong by my concept. Now everything goes well after looking into augmented reality concepts. now I'm using BeyondAR Agumented Reality SDK from here enter link description here .
Add camera preview as layer for Mapview in Android
-
15-10-2022 - |
Вопрос
Currently, I'm working on a App which contain Map. in this I would like to add my camera preview as Mapview's background or layer. which means, All place markers shows only one my camera preview. . Actually concept behind in this is, when I open my camera activity, it's shows nearby place marker on it. so when I click that marker, it's shows popup which contains place details. as shown in image. How can I implement this please. please give me any idea. I have tried with camera preview on background and mapview on foreground and setAlpha(0);, and remove all layers on mapview and so on. nothing workout for me. Kindly help me to found out the solution. Thanks in advance.
Update:
This is how I have add my camera preview:
FrameLayout preview = (FrameLayout) findViewById(R.id.camera_preview);
cameraSurfaceView = new CameraSurfaceView(this);
preview.addView(cameraSurfaceView);
and this is how I have add my MapView:
<?xml version="1.0" encoding="utf-8"?>
<com.nutiteq.MapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/transparent_background" />
<FrameLayout
android:id="@+id/camera_preview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</RelativeLayout>
mapView = (MapView) findViewById(R.id.mapView);
I have tried to mapView.setAlpha(0f);
but this hide mapview together with marker. nothing could see .
I have tried to set
Canvas can = new Canvas();
can.drawColor(0x7FFFFFFF);
mapView.draw(can);
but this one also not works.
there is some method called addLayer();
but I don't know how to convert my camera preview as layer.
Решение 2
Другие советы
I am afraid using Nutiteq MapView
on top of other views is not possible. MapView
is based on GLSurfaceView
class and its ordering vs other views is limited - it can be only the bottom most view. This is a GLSurfaceView
limitation in Android.
I'm not sure if I have understood right, you want a drawable
of a camera preview
as background, don't you?
If that's what you want, then you can capture or screenshot your camera preview
View like this
# Build the Drawing Cache
view.buildDrawingCache();
# Create Bitmap
Bitmap cache = view.getDrawingCache();
# Save Bitmap
saveBitmap(cache);
view.destroyDrawingCache();
Then you could work with this screenshot as you want.
I hope, this could help you.
Kind Regards
p.s. I found this info here to capture sights of my Views and since then I often use it.