Skip to content

Commit 98855d0

Browse files
authored
Ensure Grid and focus markers are shown (#62)
1 parent b9f0f27 commit 98855d0

File tree

4 files changed

+26
-27
lines changed

4 files changed

+26
-27
lines changed
Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<merge xmlns:android="http://schemas.android.com/apk/res/android">
2+
<!-- This FL could be removed, I added to test if we could implement
3+
proper cropping with SurfaceView. I was not easily able to. -->
4+
<FrameLayout
5+
xmlns:android="http://schemas.android.com/apk/res/android"
6+
android:id="@+id/surface_view_root"
7+
android:layout_width="match_parent"
8+
android:layout_height="match_parent"
9+
android:layout_gravity="center"
10+
android:gravity="center">
311

4-
<!-- This FL could be removed, I added to test if we could implement
5-
proper cropping with SurfaceView. I was not easily able to. -->
6-
<FrameLayout
7-
android:id="@+id/surface_view_root"
12+
<SurfaceView
13+
android:id="@+id/surface_view"
814
android:layout_width="match_parent"
9-
android:layout_height="match_parent"
10-
android:layout_gravity="center"
11-
android:gravity="center">
15+
android:layout_height="match_parent" />
1216

13-
<SurfaceView
14-
android:id="@+id/surface_view"
15-
android:layout_width="match_parent"
16-
android:layout_height="match_parent" />
17-
18-
</FrameLayout>
19-
</merge>
17+
</FrameLayout>
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<merge xmlns:android="http://schemas.android.com/apk/res/android">
3-
4-
<TextureView
5-
android:id="@+id/texture_view"
6-
android:layout_width="match_parent"
7-
android:layout_height="match_parent"
8-
android:gravity="center"
9-
android:layout_gravity="center" />
10-
11-
</merge>
2+
<TextureView
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:id="@+id/texture_view"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
android:gravity="center"
8+
android:layout_gravity="center" />

cameraview/src/main/views/com/otaliastudios/cameraview/SurfaceCameraPreview.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.content.Context;
44
import android.support.annotation.NonNull;
5+
import android.view.LayoutInflater;
56
import android.view.Surface;
67
import android.view.SurfaceHolder;
78
import android.view.SurfaceView;
@@ -25,7 +26,8 @@ class SurfaceCameraPreview extends CameraPreview<View, SurfaceHolder> {
2526
@NonNull
2627
@Override
2728
protected View onCreateView(Context context, ViewGroup parent) {
28-
final View root = View.inflate(context, R.layout.surface_view, parent); // MATCH_PARENT
29+
View root = LayoutInflater.from(context).inflate(R.layout.surface_view, parent, false);
30+
parent.addView(root, 0);
2931
mSurfaceView = root.findViewById(R.id.surface_view);
3032
final SurfaceHolder holder = mSurfaceView.getHolder();
3133
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

cameraview/src/main/views/com/otaliastudios/cameraview/TextureCameraPreview.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.content.Context;
55
import android.graphics.SurfaceTexture;
66
import android.support.annotation.NonNull;
7+
import android.view.LayoutInflater;
78
import android.view.Surface;
89
import android.view.TextureView;
910
import android.view.View;
@@ -20,7 +21,8 @@ class TextureCameraPreview extends CameraPreview<TextureView, SurfaceTexture> {
2021
@NonNull
2122
@Override
2223
protected TextureView onCreateView(Context context, ViewGroup parent) {
23-
final View root = View.inflate(context, R.layout.texture_view, parent); // MATCH_PARENT
24+
View root = LayoutInflater.from(context).inflate(R.layout.texture_view, parent, false);
25+
parent.addView(root, 0);
2426
TextureView texture = root.findViewById(R.id.texture_view);
2527
texture.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
2628

0 commit comments

Comments
 (0)