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. 10
      cameraview/src/main/res/layout/surface_view.xml
  2. 7
      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,9 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?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
<!-- This FL could be removed, I added to test if we could implement
proper cropping with SurfaceView. I was not easily able to. --> proper cropping with SurfaceView. I was not easily able to. -->
<FrameLayout <FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/surface_view_root" android:id="@+id/surface_view_root"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -15,5 +14,4 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
</FrameLayout> </FrameLayout>
</merge>

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

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

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

Loading…
Cancel
Save