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.
精彩评论