【问题标题】:creating a camera view with button for android使用 android 按钮创建相机视图
【发布时间】:2011-08-29 21:34:58
【问题描述】:

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

<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>

有没有办法让我在视图中添加一个按钮?

【问题讨论】:

    标签: android android-camera


    【解决方案1】:

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

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

    【讨论】:

    • 我在确定当前布局之前尝试过这种布局,但相对布局不起作用
    【解决方案2】:

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

    【讨论】:

    • 你说得对。我编辑了我的答案。但是,我确实认为这是可能的,尽管它不是“有意的”。
    猜你喜欢
    • 1970-01-01
    • 2020-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-23
    • 1970-01-01
    相关资源
    最近更新 更多