Is it possible to have a split screen that would have a camera preview and a second activity in the same screen? Would fragments do the job? (I am new to android and never worked with fragments). I am converting the screen colors from RGB into HSV (using OpenCV) and would like to manipulate values of H, S and V using seek bars. At the moment I am doing this in the following way:
1)press button to go to a new activity and set the values using seek bars
2)press button to go back to camera preview and get the HSV values using intents
But this involves a lot of switching between activities and checking whether I achieved the desired effect and I would like to achieve a real time preview so when changing the values I immediately see the changes. Is there any way to do that?
The Camera preview simply writes on a SurfaceView. You can put the preview anywhere you want and any size you want just like any other View object. I do think a current limitation is you can't move the preview once it's set without first disabling the camera (though not 100% sure).
As such, you can put the SurfaceView and your other View in a LinearLayout. Give them both the same weight, and both views will take up half the screen (assuming they're the only two in the layout).
Related
I have requirement where in I have to overlay a header and footer over the camera. There is a set of three button which will handle the even of camera like (click/retake).
As of now i create a surface to use as preview and add jpegcallback and picture callback to take picture and store it. I manually handle android camera hardware and parameter configuration. As all of us know there has issues around camera and picture orientation. I have worked around this by setting camera orientation and also by rotating my captured image. Though the approach looks ugly i am able to achieve the end goal.
It would be great if we have a way of overriding the android default camera activity as any of the above steps are not required. I come from a Java/Java EE background and as per my understanding we should be able to create a custom Activity and override the behaviors and properties.
My Question:
Can we override the activities for android.provider.MediaStore.ACTION_IMAGE_CAPTURE and also com.android.camera.action.CROP.
If so which package of android has the java class for this activities.
Hopefully I am not misunderstanding your question but it sounds like you want to use the camera in your app. You want to view what the camera is seeing while having a header and footer above and below the camera preview. Then you want these buttons to do things like take a picture, etc.
If I am wrong I apologize.
Just look at the Camera implementation in the docs.
http://developer.android.com/guide/topics/media/camera.html#custom-camera
You can create your own activity layout with any buttons/text above, below, or on top of a preview view that you use to display the camera feed. Then just use the on click events for the buttons or whatever to do the things you want. Majority of this is in the documentation in the link.
I wanna start a new project. A little "Jump n Run", but I have questions:
The levels will be bigger than the screen. How can I make a big Layout and edit it?
And how do the view "follows" the player, if he moves.
I dont want code samples. I only want basic ideas how to do it.
I suggest you have a look at the SurfaceView. It allows you to render bitmaps to the screen. In your case you could create a bitmap that is larger than the screen and have the user navigate it with the use of their finger (so you'll also have to also use your touchscreen). Basically what you will be changing when the user wants to go to a new location would be the src rect parameter in the drawBitmap method.
I hope this gets you started.
You could specify the layout to whatever pixel size you want (even if it's larger than any screen size would be), and then use scroll views to allow the user to scroll to other areas of the screen. Check out the Android developer docs on horizontal scroll view.
I use a navigation-based iOS application. I want to make a background similar to desktop wallpaper in Android.
So when I go to another View the current View and it's content goes outside of the screen but the background image slightly moves only.
See a sample screenshot here.
Why not have the base subview set to the size of the background wallpaper (ie larger than the screens width) and start with it left aligned. Then have a paged UIScrollView on top of that. When the user scrolls the UIScrollview, hook into the UIScrollViewDelegate method
- scrollViewDidScroll: and pass it through the the base subview, telling it to animate in accordance.
This shouldn't be too hard but you'll probably want to tweak it a bit to get the feel you want.Try playing about with the various delegate methods in the UIScrollViewDelegate protocol to determine the best time to start the animation.
I have a 'Portrait mode' tabbed based application that contains a SurfaceView (with a camera preview on it) within one of the tabs. I have been creating my camera code from the Android API Demos and I have it all set-up working correctly bar one thing. The resulting camera preview is stretched and scaled making the preview look off.
Ideally I want to render the SurfaceView at the native preview size defined by the camera within the tab. However that would involve making the contents of the tab larger than its parent! (Or rather larger than the FrameLayout the tab activities are contained in).
How can I go about Achieving this?
Image of problem:
Make the FrameLayout the root object, then pile the camera view in it, then header and the tab widget. You may have to do some fancy work with gravity settings and stacking the header/footer in linear layouts but it definitely is possible.
aka:
frame.addView(cameraPreview);
frame.addView(header);
frame.addView(footer);
This will draw the objects in layers.
EDIT: If you don't want to use your current frame layout, just make another one. Stack the header, frame layout, and footer inside a linear layout. Create a new frame layout, add the linear layout to it, then add the preview onto it to draw over it.
I'm entirely new to Android development, and I'm interested in making a live wallpaper. I was thinking about looping a set of pictures instead of drawing the animation. Is this a possible approach? If possible is this a suitable or ideal way of doing it, does it eat up memory and would i need images with different resolutions because of the fragmentation?(hundreds of different devices)
Thanks in advance :)
Sure, it should be fairly simple.
The main part of the Wallpaper engine is the Drawing of course. You need to handle the drawing manually, there is no easy way to loop through images... you need to code it. You will have to continuously monitor the time which has passed and adjust the displayed image based on that. You are given a Canvas object to draw to and it is all done during run-time in code.
The Wallpaper engine class has a event called onSurfaceChanged which gives you the width and height of the Surface which you will be drawing to. It will be called everytime the screen dimensions change (like if the phone is put into Landscape mode for instance). You need to have code that will handle any combination of width or height for all the device types out there. You will need to decide if you are going to stretch, center, tile or crop (Or a combination of those) the source images to fit any particular screen size. I would recommend scale to fit so that the image is either taller or wider than the screen and center the image either vertically or horizontally (cropping the extra bits) once that is done. I personally just use one source size and resize it to fit. You can opt to use several source files if you want which is the recommended approach I believe, but it's a little confusing.
I would start by creating a Live Wallpaper which just draws something basic like a shape to the screen. Then work out how to display an custom image and take it from there.
Good luck
You will need to be very careful about memory if taking a frame approach to animation--probably will not be possible to animate full frames--much more practical to move sprites on a background. See, fr'instance: http://davidjhinson.wordpress.com/2010/05/19/scarce-commodities-google-android-memory-and-bitmaps/
what if you have a png frame animation that is set at a certain x and y position that sits in a spot on the background image, both would have to be rescaled