Ensure Grid and focus markers are shown (#62)

pull/50/head^2
Mattia Iavarone 7 years ago committed by GitHub
parent b9f0f27d8d
commit 98855d0976
  1. 28
      cameraview/src/main/res/layout/surface_view.xml
  2. 17
      cameraview/src/main/res/layout/texture_view.xml
  3. 4
      cameraview/src/main/views/com/otaliastudios/cameraview/SurfaceCameraPreview.java
  4. 4
      cameraview/src/main/views/com/otaliastudios/cameraview/TextureCameraPreview.java

@ -1,19 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<!-- This FL could be removed, I added to test if we could implement
proper cropping with SurfaceView. I was not easily able to. -->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/surface_view_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center">
<!-- This FL could be removed, I added to test if we could implement
proper cropping with SurfaceView. I was not easily able to. -->
<FrameLayout
android:id="@+id/surface_view_root"
<SurfaceView
android:id="@+id/surface_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center">
android:layout_height="match_parent" />
<SurfaceView
android:id="@+id/surface_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
</merge>
</FrameLayout>

@ -1,11 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<TextureView
android:id="@+id/texture_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_gravity="center" />
</merge>
<TextureView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/texture_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_gravity="center" />

@ -2,6 +2,7 @@ package com.otaliastudios.cameraview;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
@ -25,7 +26,8 @@ class SurfaceCameraPreview extends CameraPreview<View, SurfaceHolder> {
@NonNull
@Override
protected View onCreateView(Context context, ViewGroup parent) {
final View root = View.inflate(context, R.layout.surface_view, parent); // MATCH_PARENT
View root = LayoutInflater.from(context).inflate(R.layout.surface_view, parent, false);
parent.addView(root, 0);
mSurfaceView = root.findViewById(R.id.surface_view);
final SurfaceHolder holder = mSurfaceView.getHolder();
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

@ -4,6 +4,7 @@ import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.Surface;
import android.view.TextureView;
import android.view.View;
@ -20,7 +21,8 @@ class TextureCameraPreview extends CameraPreview<TextureView, SurfaceTexture> {
@NonNull
@Override
protected TextureView onCreateView(Context context, ViewGroup parent) {
final View root = View.inflate(context, R.layout.texture_view, parent); // MATCH_PARENT
View root = LayoutInflater.from(context).inflate(R.layout.texture_view, parent, false);
parent.addView(root, 0);
TextureView texture = root.findViewById(R.id.texture_view);
texture.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {

Loading…
Cancel
Save