【问题标题】:How to implement JavaCameraView on top of screen如何在屏幕顶部实现 JavaCameraView
【发布时间】:2018-01-30 15:51:19
【问题描述】:

所以目前我在处理我的问题时遇到了麻烦。我想要实现的基本上是打开一个JavaCameraView,同时仍然能够正常操作手机。 我已经设法遵循指南here 并在我的styles.xml 文件中使用了它

<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>

这个xml实现的是它成功的让背景透明了,但是我不能点击背景上的任何东西。

如果我希望能够点击背景项目(正常操作我的手机),同时将JavaCameraView 保持在顶部,我该如何实现?

如果需要,这是我的onCreate() 代码。

@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>

非常感谢。

【问题讨论】:

    标签: android opencv


    【解决方案1】:

    所以我发现我需要的是一个浮动窗口。

    我会留下一个链接here,它可以帮助我解决我的问题,以帮助任何与我有同样问题的人。

    干杯。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-16
      • 2015-10-23
      • 1970-01-01
      • 1970-01-01
      • 2011-11-08
      • 2015-04-09
      • 2017-05-20
      相关资源
      最近更新 更多