Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Set view w/h programatically

So I am working with the camera API (1 not 2) and I am displaying its output on a surface. In landscape mode the camera is capturing in 16:9 so having my CameraPreiviewView hard set to 200dp x 133dp. However in portrait mode it captures in 4:3 (i am guessing) so a hard coded w/h on the view doesn't look right, things get skewed. If I set the view to wrap_content the image displays very clean and maintains its proper aspect ratio. however it takes up 100% of the screen which isn't what I want.

Is there a way to do this programatically or do I need to wrap the view in another container and specify a max w/h on that?

Ben Jakuben, Ben Deitch or anyone else know how to do this?