我想在安卓的JavaCameraView上覆盖透明的TextView,如图所示。我该怎么做呢?我试图将TextView放在JavaCameraView中,但是没有起作用。

<org.opencv.android.JavaCameraView
android:id="@+id/activity_java_surface_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />发布于 2019-03-19 00:25:58
您应该使用ConstraintLayout或RelativeLayout。在这些视图中,可以将视图放在彼此的顶部。
试试这个:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<org.opencv.android.JavaCameraView
android:id="@+id/activity_java_surface_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<TextView
android:id="@+id/text_overlay"
android:layout_width="0dp"
android:layout_height="60dp"
android:text="test text"
android:background="#00000000"
app:layout_constraintBottom_toBottomOf="@id/activity_java_surface_view"
app:layout_constraintEnd_toEndOf="@id/activity_java_surface_view"
app:layout_constraintStart_toStartOf="@id/activity_java_surface_view"
/>https://stackoverflow.com/questions/55225722
复制相似问题