1

我有你在图片中看到的布局(抱歉我还不能正常发布它们): https ://dl.dropboxusercontent.com/u/28640502/Unbenannt.bmp

但是,当我执行应用程序时,我只能看到相机预览,而不是文本或 SeekBar。我知道它们可以工作,因为当我缩小相机尺寸时,我可以看到它们并进行交互,但如果我想让相机像背景一样,然后是孩子们在它上面,它就行不通了。

我一直在检查很多有类似问题的线程,但我没有找到解决方案: 1 , 2 , 3 ... 知道吗?非常感谢!

这是我的xml代码以防万一:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="0.55"
    android:orientation="vertical" >

    <FrameLayout
        android:id="@+id/camera_preview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="fill">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/show_height"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="5sp"
                android:layout_marginRight="10sp"
                android:layout_weight="0.12"
                android:text="H" />

            <SeekBar
                android:id="@+id/select_height"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                android:layout_margin="5sp"
                android:layout_weight="0.91" />

            <TextView
                android:id="@+id/show_distance"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="0.06"
                android:text="Dist" />
        </LinearLayout>

    </FrameLayout>

</LinearLayout>
4

2 回答 2

2

尝试以相对布局输入您的两个布局,例如

<LL>
  <RL>
    <FL>
    </FL>
    <LL>
    </LL>
  </RL>
</LL>

这是因为 FL 覆盖了 LL

于 2013-09-18T07:46:19.110 回答
1

您可以使用 View 类的 bringToFront() 方法。

SeekBar seeker = (SeekBar)findViewById(R.id.select_height);
seeker.bringToFront();

或者,您可以使用 sendToBack() 函数将视图放在其他视图后面。

还要记住,视图的 z-index 由视图在 xml 布局文件中声明的顺序决定。

我还建议更改相机预览布局,并将其作为兄弟姐妹的第一个子布局。xml 文件中最后添加的那个将位于顶部。

于 2013-09-18T07:45:27.657 回答