Skip to content
This repository was archived by the owner on Jun 14, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
int childHeight = (int) (childWidth / previewSizeRatio);
if (childHeight <= layoutHeight) {
for (int i = 0; i < getChildCount(); ++i) {
getChildAt(i).layout(0, 0, childWidth, childHeight);
getChildAt(i).layout(0, 0, childWidth, getHeight());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC matching container's height forcibly will cause the camera frame distortion if the aspect ratio of camera preview is different than the container. For example, camera ratio is 16 : 9 and container ratio is 17 : 9, then this change will stretch the camera frame to have ratio 17 : 9.

}
} else {
// When the child view is too tall to be fitted in its parent: If the child view is static
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class CameraSourcePreview(context: Context, attrs: AttributeSet) : FrameLayout(c
val childHeight = (layoutWidth / previewSizeRatio).toInt()
if (childHeight <= layoutHeight) {
for (i in 0 until childCount) {
getChildAt(i).layout(0, 0, layoutWidth, childHeight)
getChildAt(i).layout(0, 0, layoutWidth, height)
}
} else {
// When the child view is too tall to be fitted in its parent: If the child view is
Expand Down