java - 如何在 SurfaceView 上正确覆盖 UI Widgets?

标签 java android android-widget camera

我有一个在 RelativeLayout、一个按钮和一个 TextView 中工作的人像相机预览。它们在那里,但不可见,它们对触摸 Action 做出正确 react 。如何设置 Z-Order 或优先级? 这是我的 main.xml:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
    android:layout_height="fill_parent"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+layout/frame"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

<SurfaceView android:id="@+id/surface" android:layout_width="fill_parent" android:layout_height="fill_parent"></SurfaceView>
<Button android:layout_height="wrap_content" android:layout_width="match_parent" android:onClick="hablar" android:text="Button" android:id="@+id/button1"></Button>
<EditText android:layout_height="wrap_content" android:layout_width="match_parent" android:text="EditText" android:id="@+id/edita"></EditText>
</RelativeLayout>
</FrameLayout>

最佳答案

只需在 SurfaceView 上放置一个 View :

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">

    <SurfaceView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <View
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="lalalalala" />
</FrameLayout>

关于java - 如何在 SurfaceView 上正确覆盖 UI Widgets?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6480584/

相关文章:

java - 类中定义的枚举是静态嵌套类吗?

java - 序列化 - 使用 ObjectStreamField [] serialPersistentFields 有什么好处?

android - 在 Android Studio 中添加 android.jar 作为模块的依赖项

java - 将 LinearLayout 调整为 ImageView 的宽度

java - Hello Android 应用程序未显示在 Android 模拟器中

java - 当我检查空概率时,检查显示空指针异常

java - 在java中用字符串替换正则表达式

java - Android Java GUI freeze/w ProgressBar

android - 按钮 setOnClickListener 上的 NullPointerException

android - 在每个方向缩放 RectF 对象