1

So currently i am having troubles on dealing with my problems. What I want to achieve basically is to open a JavaCameraView while still be able to operate the phone normally. I have managed to follow the guide here and used this in my styles.xml file

<resources>
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:backgroundDimEnabled">false</item>
    </style>
</resources>

What this xml has achieved is that it has successfully managed to make the background transparent, but I can't click anything on the background.

If I want to be able to click background items (operate my phone normally), while keeping the JavaCameraView on top, how can i achieve that?

Here is my onCreate() code if needed.

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "onCreate");
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_main);

    mOpenCvCameraView = (JavaCameraView) findViewById(R.id.tutorial1_activity_java_surface_view);
    mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
    mOpenCvCameraView.setCvCameraViewListener(this);

    mOpenCvCameraView.setZOrderOnTop(true);
    SurfaceHolder CameraViewHolder = mOpenCvCameraView.getHolder();
    CameraViewHolder.setFormat(PixelFormat.TRANSPARENT);
}

activity_main.xml

[<!-- language: xml -->]
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:opencv="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.os10.testproject.MainActivity">

    <org.opencv.android.JavaCameraView
        android:id="@+id/tutorial1_activity_java_surface_view"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_gravity="top"
        android:screenOrientation="portrait"
        android:visibility="visible"
        opencv:camera_id="front"
        opencv:show_fps="true" />
</RelativeLayout>

Many thanks.

Victor Arsjad
  • 53
  • 1
  • 5

1 Answers1

0

So i found out that what i need is a floating window.

I will leave a link here which helps me in solving my problem to help anyone having the same problem as mine.

Cheers.

Victor Arsjad
  • 53
  • 1
  • 5