Probably the same(ish) way as doing as a content. A couple of things to thing about:
1) Make sure the view you intend to draw on has a predefined size. If not, it may (will likely) be shrunk to 0px wide and 0px tall.
2) You may find it easiest to position things with a RelativeLayout to avoid unwanted resizing
3a) You may find it easier to make the layout with the surface view in it, then get it out of the view using findViewById()
3b) Alternatively,
you should put a placeholder FrameLayout where you want the surface view, then get the FrameLayout using findViewById() and adding your surface view to the frame
If you are having problems, show the layout, a simple version of the code, and a screenshot of the results, and details about the difference between expectations and results so we can help you with the issue.