我正在使用两个MjpegView (扩展SurfaceView的自定义视图)构建一个应用程序。问题是,有时我没有看到第二个摄像机视图,因为它在第一个摄像机视图后面。流的工作没有任何问题,我试图改变相机内部的位置视图的布局,但没有任何成功,也尝试了前面(第二个摄像头)。
这是自我布局的代码,
谢谢
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/visul_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/camera_border"
android:padding="2dp" >
<TextView
android:id="@+id/no_visu_stream"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/measurment_no_stream"
android:textColor="@android:color/white"
android:textSize="25sp" />
<com.example.test.views.MjpegView
android:id="@+id/sh_surface"
android:layout_alignParentBottom="true"
android:layout_width="150dp"
android:layout_height="150dp"
android:visibility="gone" />
<com.example.test.views.MjpegView
android:id="@+id/visul_surface"
android:layout_width="match_parent"
android:layout_margin="2dp"
android:layout_height="500dp"
android:visibility="gone" />
<ImageView
android:id="@+id/cible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/cible"
android:visibility="gone" />
<TextView
android:id="@+id/no_sh_stream"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerInParent="true"
android:text="@string/measurment_no_stream"
android:textColor="@android:color/white"
android:textSize="14sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/eye_left_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:padding="10dp" >
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/motor_arrow_selector_left" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/eye_right_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="15dp"
android:padding="10dp" >
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/motor_arrow_selector_right" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/eye_up_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:padding="10dp" >
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/motor_arrow_selector_up" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/eye_down_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="15dp"
android:padding="10dp" >
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/motor_arrow_selector_down" />
</RelativeLayout>
<ImageView
android:id="@+id/disable_camera_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/disable_camera_layout"
android:clickable="true"
android:visibility="gone" />
</RelativeLayout>发布于 2015-03-05 16:50:47
(我不确定这是一个简单的布局问题还是与SurfaceView曲面重叠的问题;我将把它作为第二个问题来处理。)
SurfaceView曲面存在于一个独立的层上,独立于用于呈现视图层次结构的图形层。SurfaceView的“视图”部分只是一个透明的洞,可以让您通过视图层看到曲面。
每个表面层都有一个Z序.如果两个曲面试图占据相同的空间,其中一个将获胜,而胜利者并不完全是决定性的。您可以通过显式设置其中一个曲面的Z顺序来解决此问题。setZOrderMediaOverlay()调用将将该层定位在默认表面位置之上,但位于视图层以下。setZOrderOnTop()将将该表面放置在视图UI之上。必须在创建曲面之前进行调用(例如,在onCreate()中)。
例如,请参阅Grafika中的"多面试验“活动。
https://stackoverflow.com/questions/28873710
复制相似问题