32834

How to set Camera View as background with views over it?

Question:

So, I'm trying to make the background to one of my apps look "futuristic." I thought of an idea to make the screen look almost transparent yet have views over it. So, it would look something like this: <a href="http://c2499022.cdn.cloudfiles.rackspacecloud.com/wp-content/uploads/2009/08/window-phone-concept.jpg" rel="nofollow">this. http://c2499022.cdn.cloudfiles.rackspacecloud.com/wp-content/uploads/2009/08/window-phone-concept.jpg</a>

I'm thinking that I can use the camera to capture the background of the phone (without taking a picture, just having the real time view in the background) and then, if possible, place a semi-transparent slightly blurred ImageView over that. Finally, on top of that I can place the other views including the ImageButtons.

So, my question is how would I go about doing this? I have searched but haven't found anything relevant. It must be possible; its just how to do it? I don't expect you to give me all the code as an answer, just if you have any ideas that can help or links or code that can point me in the right direction, it would be greatly appreciated! Thanks!

Answer1:

It shouldn't be too hard to get started. There are samples located <a href="http://developer.android.com/training/camera/cameradirect.html" rel="nofollow">here</a> that show you how to open the camera and draw the preview onto a SurfaceView. Since you want to overlay your other Views on top of the camera preview, just make sure that the SurfaceView that you are using for the camera preview is contained inside a FrameLayout (docs located <a href="http://developer.android.com/reference/android/widget/FrameLayout.html" rel="nofollow">here</a>). The FrameLayout lets you insert child views and they are z-indexed using the order they are inserted. Therefore, if you insert your SurfaceView and then insert a Button of some kind it will be z-ordered in front of the SurfaceView and you can set its alpha value so that it can be more or less transparent. All that said, you will have to do some trial and error for how you want to position your views that are being rendered in front of the camera preview because a FrameLayout used on different screen sizes might position the Views differently. Also, I'd stay away from layering too many Views on top of one another because the compositor will have to figure out how to render all of it into a single window which could impact performance.

Recommend

  • Circular CAGradientLayer Mask
  • Partially blurring UIImage in objective C
  • How to create loading screen in android?
  • Frame of animated GIF only showing deltas
  • How to have rotated Ellipse shape in Java?
  • Javadoc generation for Android
  • str_replace with line break? [closed]
  • How to calculate total Fridays between two dates in excel on weekly, biweekly and monthly basis?
  • How to restrict number of concurrent processes?
  • iPhone: 5 seconds video capture
  • Selenium and Google - How do you use cookies?
  • Printing out Japanese (Chinese) characters
  • How to get a android ListView item selector to use state_pressed
  • Use neo4j server instead of embedded mode
  • Picasso Taking time to load images
  • write text on image and show it to a imageview
  • Certain Arabic text gets incorrectly shown while other Arabic text gets showed normally?
  • Is there a way to call library thread-local init/cleanup on thread creation/destruction?
  • How to change placeholder text in an autocomplete activity of android google place?
  • Classic ASP URL Rewriting
  • Efficient User-Agent Regex to find Safari in Python
  • How to remove a SwiftyJSON element?
  • Android application: how to use the camera and grab the image bytes?
  • Breaking out column by groups in Pandas
  • How solve “Qt: Untested Windows version 10.0 detected!”
  • Excel's Macro-Recorder usage
  • How to use carriage return with multiple line?
  • Time complexity of a program which involves multiple variables
  • Ajax jQuery multiple calls at the same time - long wait for answer and not able to cancel
  • Is my CUDA kernel really runs on device or is being mistekenly executed by host in emulation?
  • Java applet as stand-alone Windows application?
  • How to set my toolbar fixed while scrolling android
  • Weird JavaScript statement, what does it mean?
  • Cannot Parse HTML Data Using Android / JSOUP
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • Getting Messege Twice Using IMvxMessenger
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • need help with bizarre java.net.HttpURLConnection behavior
  • Android Heatmap on canvas or ImageView
  • How to load view controller without button in storyboard?