William Stewart
William Stewart

Reputation: 841

Change size of FrameLayout when screen size has been found

At the moment I have a FrameLayout which will hold a preview of a picture taken. The size of this is determined in the layout xml file I created for it, at the moment its just set to fill_parent. However the image taken is at 4:3 aspect ratio, but this isn't always going to be the right aspect ratio for the users screen.

For example with my Xperia X10 which is 480 X 854, the 4:3 image taken by the camera always stretches to fit the FrameLayout.

What I want to do is change the size of the FrameLayout outside of the XML file so that it is 4:3 and a size appropriate for the users screen size. Any ideas?

Upvotes: 1

Views: 3960

Answers (2)

Abhay Kumar
Abhay Kumar

Reputation: 1618

 Framelayout.LayoutParams lp = new LinearLayout.LayoutParams(width, height);
 lv.setLayoutParams(lp);

Try using the above code...

Upvotes: 0

user658042
user658042

Reputation:

I guess you are using an ImageView inside your FrameLayout to display the actual picture? In this case, use scaleType to define how the picture should be stretched.

You can set that in your XML, just use android:scaleType=".." inside your ImageView tag.

Upvotes: 2

Related Questions