用android按钮创建摄像机视图

时间:2011-08-29 21:34:58

标签: android android-camera

我已经设置了一个活动来加载相机并允许我预览它但我需要在屏幕上添加一个按钮,但我可以通过使用以下布局来显示屏幕的唯一方法:

<android.view.SurfaceView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myview"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.view.SurfaceView>

我有办法在视图中添加按钮吗?

2 个答案:

答案 0 :(得分:0)

SurfaceView和按钮放入RelativeLayout。这两种类型的布局都允许视图重叠,因此您的按钮将位于SurfaceView之上。设置将是这样的

<RelativeLayout>  
    <SurfaceView></SurfaceView>  
    <Button></Button>  
 </RelativeLayout>

答案 1 :(得分:-1)

DeeV的答案对于RelativeLayout部分是正确的。 FrameLayout不包含多个子项。所以RelativeLayout是要走的路。