{"id":6354,"date":"2014-04-17T00:56:49","date_gmt":"2014-04-17T00:56:49","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/17\/android-how-to-create-invisible-camera-preview-for-video-recording-collection-of-common-programming-errors\/"},"modified":"2014-04-17T00:56:49","modified_gmt":"2014-04-17T00:56:49","slug":"android-how-to-create-invisible-camera-preview-for-video-recording-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/17\/android-how-to-create-invisible-camera-preview-for-video-recording-collection-of-common-programming-errors\/","title":{"rendered":"Android &#8211; How to create invisible camera preview for video recording?-Collection of common programming errors"},"content":{"rendered":"<p>I want to create hidden SurfaceView for camera preview. I tried method recommended in answer to another question:<\/p>\n<pre><code>WindowManager wm = (WindowManager) mCtx.getSystemService(Context.WINDOW_SERVICE);\nparams = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,\n        WindowManager.LayoutParams.WRAP_CONTENT,\n        WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,\n        WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,\n        PixelFormat.TRANSLUCENT);        \nwm.addView(surfaceview, params);\n\nsurfaceview.setZOrderOnTop(true);\nmHolder.setFormat(PixelFormat.TRANSPARENT);\n<\/code><\/pre>\n<p>but it isn&#8217;t invisible, in fact it takes the whole screen. I tried setting alpha or resizing it but it doesn&#8217;t work. Is there a way to making it hidden or at least resizing it to 1&#215;1 size?<\/p>\n<p><strong>EDIT:<\/strong><\/p>\n<p>I would also add that simply placing 1&#215;1 <code>SurfaceView<\/code> in activity layout wouldn&#8217;t work in my case because I use multiple layouts and I believe <code>Views<\/code> are destroyed on layout change&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I want to create hidden SurfaceView for camera preview. I tried method recommended in answer to another question: WindowManager wm = (WindowManager) mCtx.getSystemService(Context.WINDOW_SERVICE); params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSLUCENT); wm.addView(surfaceview, params); surfaceview.setZOrderOnTop(true); mHolder.setFormat(PixelFormat.TRANSPARENT); but it isn&#8217;t invisible, in fact it takes the whole screen. I tried setting alpha or resizing it but it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6354","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6354"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6354\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}