开发者

creating a camera view with button for android

开发者 https://www.devze.com 2023-03-31 09:05 出处:网络
i have set up an activity that loads up the camera and allows me to preview it but i need to add a button to the screen but the only way i can get the screen to display is by using the following layou

i have set up an activity that loads up the camera and allows me to preview it but i need to add a button to the screen but the only way i can get the screen to display is by using the following layout:

<android.view.SurfaceView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myview"
android:layout_width="match_parent"
andro开发者_如何学编程id:layout_height="match_parent">
</android.view.SurfaceView>

is there a way for me to add a button to the view?


Put your SurfaceView and button into a RelativeLayout. Both of those types of layouts allow views to overlap so your button will be on top of your SurfaceView. The set up would be something like this

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


DeeV's answer is correct for the RelativeLayout part. The FrameLayout isn't intented to contain multiple children. So the RelativeLayout is the way to go.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号