本文介绍了Android - 如何使用相机 getSupportedPreviewSizes() 进行纵向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在活动中嵌入相机预览.而且它只是在纵向.问题是预览被拉长了.

我已尝试选择最佳尺寸.但问题是 getSupportedPreviewSizes() 中所有支持的预览尺寸返回横向尺寸.所以我猜根据我的代码选择合适的尺寸是行不通的.

我的布局

<线性布局android:layout_width="match_parent"android:layout_height="wrap_content"><编辑文本android:layout_width="0dp"android:layout_height="wrap_content"机器人:layout_weight="1"android:hint="@string/take_attendance_manual_text"/><按钮android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/take_attendance_manual_button"android:id="@+id/take_attendance_manual_button"/></LinearLayout></LinearLayout>

这是我的 CameraPreview 类:

package com.lab.rafael.smartattendance.camera;导入 android.content.Context;导入 android.hardware.Camera;导入 android.util.Log;导入 android.view.SurfaceHolder;导入 android.view.SurfaceView;导入 java.io.IOException;导入 java.util.List;公共类 CameraPreview 扩展 SurfaceView 实现 SurfaceHolder.Callback {私人相机 mCamera = null;私人 SurfaceHolder mHolder = null;private Camera.Size optimizationSize = null;public CameraPreview(上下文上下文,相机相机){超级(上下文);mCamera = 相机;mHolder = getHolder();mHolder.addCallback(this);}@覆盖公共无效表面创建(SurfaceHolder 持有人){尝试 {Camera.Parameters params = mCamera.getParameters();列表focusModes = params.getSupportedFocusModes();mCamera.setDisplayOrientation(90);mCamera.setPreviewDisplay(holder);if(focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);}if(optimalSize != null) {params.setPreviewSize(optimalSize.width,optimalSize.height);}mCamera.setParameters(params);mCamera.startPreview();} catch (IOException e){Log.e("created_error", e.getMessage());}}@覆盖public void SurfaceChanged(SurfaceHolder 持有人,int 格式,int 宽度,int 高度){if(mHolder.getSurface() == null) {返回;}尝试 {mCamera.stopPreview();} 捕获(异常 e){Log.e("changed_error", e.getMessage());}尝试 {mCamera.setPreviewDisplay(holder);mCamera.startPreview();} catch (IOException e){Log.e("error", e.getMessage());}}@覆盖public void onMeasure(int measureWidthSpec, int measureHeightSpec) {bestSize = getOptimalSize(MeasureSpec.getSize(measureWidthSpec), MeasureSpec.getSize(measureHeightSpec));setMeasuredDimension(optimalSize.width,optimalSize.height);}受保护的 Camera.Size getOptimalSize(int width, int height) {列表<Camera.Size>supportedSizes = mCamera.getParameters().getSupportedPreviewSizes();double targetRatio = (double) 宽/高,最优比率 = 0.0,可接受的RatioMargin = 0.1,minDiff = Double.MAX_VALUE;for(Camera.Size size : supportedSizes) {最佳比率 = (双) size.width/size.height;if(Math.abs(optimalRatio - targetRatio) 

解决方案

我遇到了和 1 年前一样的问题.另外,我不得不处理前置和后置摄像头.我不太记得代码,但我在发布这个答案之前尝试过它,它仍然像魅力一样工作.
希望您可以挖掘并与您的代码进行比较.如果你只是工作,我可以分享更多代码;)

/*** 一个围绕 Camera 和 SurfaceView 的简单包装器,用于呈现相机的居中预览* 到表面.我们需要将 SurfaceView 居中,因为并非所有设备都有摄像头* 支持与设备显示器具有相同纵横比的预览尺寸.*/公共类预览扩展 ViewGroup 实现 SurfaceHolder.Callback {SurfaceView mSurfaceView;SurfaceHolder mHolder;Camera.Size mPreviewSize;列表<Camera.Size>mSupportedPreviewSizes;相机 mCamera;私有上下文上下文;私人 int mCameraId;公共布尔 use_front_camera;公共预览(上下文上下文,int cameraId){超级(上下文);this.context = 上下文;mCameraId = 相机 ID;use_front_camera = true;mSurfaceView = new SurfaceView(context);添加视图(mSurfaceView);//安装 SurfaceHolder.Callback 以便我们在//底层表面被创建和销毁.mHolder = mSurfaceView.getHolder();mHolder.addCallback(this);}公共无效setCamera(相机相机){mCamera = 相机;如果(mCamera != null){mSupportedPreviewSizes = mCamera.getParameters().getSupportedPreviewSizes();请求布局();}}公共无效switchCamera(相机相机){设置相机(相机);尝试 {camera.setPreviewDisplay(mHolder);} catch(IOException异常){android.util.Log.e(IdelityConstants.DEBUG_IDELITY_KEY_LOG, "setPreviewDisplay() 引起的IOException", 异常);}Camera.Parameters 参数 = camera.getParameters();parameters.setPreviewSize(mPreviewSize.width, mPreviewSize.height);请求布局();相机.setParameters(参数);}@覆盖protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {//我们故意忽略子测量,因为作为//包装到一个 SurfaceView 中,而不是将相机预览居中//拉伸它.int width = MeasureSpec.getSize(widthMeasureSpec);int height = MeasureSpec.getSize(heightMeasureSpec);//必须调用这个setMeasuredDimension(宽度,高度);如果(mSupportedPreviewSizes != null){mPreviewSize = getOptimalPreviewSize(mSupportedPreviewSizes, width, height);}}@覆盖protected void onLayout(boolean 改变,int l,int t,int r,int b) {如果(改变&& getChildCount()> 0){最终视图子 = getChildAt(0);最终 int 宽度 = r - l;最终 int 高度 = b - t;int previewWidth = 宽度;int previewHeight = 高度;如果(mPreviewSize != null){/*** Como el calculo se hace con la cámara en modo Landscape y luego toca* girar la cámara para que se vea bien, se pasan los valores cambiados.*/previewWidth = mPreviewSize.height;previewHeight = mPreviewSize.width;}//在父级中居中子 SurfaceView.if (width * previewHeight < height * previewWidth) {final int scaledChildWidth = previewWidth * height/previewHeight;child.layout((width - scaledChildWidth)/2, 0,(width + scaledChildWidth)/2, height);} 别的 {final int scaledChildHeight = previewHeight * width/previewWidth;child.layout(0, (height - scaledChildHeight)/2,宽度,(高度 + scaledChildHeight)/2);}}}公共无效表面创建(SurfaceHolder 持有人){//Surface 已经创建,获取相机并告诉它在哪里//绘制.尝试 {如果(mCamera != null){mCamera.setPreviewDisplay(holder);}} catch(IOException异常){android.util.Log.e(IdelityConstants.DEBUG_IDELITY_KEY_LOG, "setPreviewDisplay() 引起的IOException", 异常);}}公共无效surfaceDestroyed(SurfaceHolder持有人){//返回时Surface 会被销毁,所以停止预览.//if (mCamera != null) {//mCamera.stopPreview();//}}private Camera.Size getOptimalPreviewSize(Listsizes, int w, int h) {最终双 ASPECT_TOLERANCE = 0.1;double targetRatio = (double) w/h;if (sizes == null) 返回 null;Camera.Size optimizationSize = null;double minDiff = Double.MAX_VALUE;int targetHeight = h;//尝试找到一个尺寸匹配纵横比和尺寸for (Camera.Size size : 尺寸) {双倍比率 = (double) size.width/size.height;如果 (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) 继续;if (Math.abs(size.height - targetHeight)  size.width)尺寸 = 尺寸.get(i);}parameters.setPictureSize(size.width, size.height);请求布局();mCamera.setParameters(参数);mCamera.setDisplayOrientation(getCameraDisplayOrientation((FragmentActivity)context, mCameraId));mCamera.startPreview();}公共静态 int getCameraDisplayOrientation(FragmentActivity 活动,int cameraId){Camera.CameraInfo info = new Camera.CameraInfo();Camera.getCameraInfo(cameraId, info);int 旋转 = activity.getWindowManager().getDefaultDisplay().getRotation();整数度 = 0;开关(旋转){case Surface.ROTATION_0:度数= 0;休息;case Surface.ROTATION_90:度数= 90;休息;案例 Surface.ROTATION_180:度数 = 180;休息;案例 Surface.ROTATION_270:度数 = 270;休息;}整数结果;如果(信息.面对== Camera.CameraInfo.CAMERA_FACING_FRONT){结果 = (info.orientation + 度数) % 360;结果 = (360 - 结果) % 360;//补偿镜像}else {//背面结果 = (info.orientation - 度数 + 360) % 360;}返回结果;}/** 一种获取 Camera 对象实例的安全方法.*/公共静态相机 getCameraInstance(int cameraIndex){相机 c = 空;尝试 {c = Camera.open(cameraIndex);//尝试获取 Camera 实例}捕获(例外 e){//相机不可用(正在使用或不存在)android.util.Log.e(IdelityConstants.ERROR_IDELITY_KEY_LOG, "相机不可用:" + e.getMessage());}返回 c;//如果相机不可用则返回 null}}



这是

<框架布局android:id="@+id/capture_evidence_camera_preview"android:layout_width="wrap_content"android:layout_height="wrap_content"机器人:layout_centerVertical =真"android:layout_centerHorizo​​ntal="true"/><文本视图android:layout_width="fill_parent"android:layout_height="wrap_content"android:text="@string/capture_evidence_default_text_number_evidence"android:id="@+id/capture_evidence_textView_value_typed"android:textSize="50sp"android:textColor="@color/ideality_blanco"机器人:重力=center_horizo​​ntal"机器人:paddingLeft =5dp"机器人:paddingRight="5dp"机器人:背景=#d2000000"机器人:layout_alignParentBottom =真"机器人:layout_centerHorizo​​ntal="true"android:paddingTop="8dp"android:paddingBottom="8dp"/></RelativeLayout><相对布局android:layout_width="fill_parent"android:layout_height="0dp"android:layout_weight="1"><net.idelity.idelitymobile.ui.helpers.IdelityButtonandroid:layout_width="wrap_content"android:layout_height="fill_parent"android:text="@string/button_back"android:id="@+id/capture_evidence_button_cancel"机器人:layout_alignParentBottom =真"机器人:layout_alignParentLeft =真"android:layout_alignParentStart="true"android:background="@drawable/button_gray"android:textColor="@color/ideality_blanco"android:textSize="20sp"机器人:paddingLeft =40dp"android:paddingRight="40dp"android:textStyle="粗体"/><net.idelity.idelitymobile.ui.helpers.IdelityButtonandroid:layout_width="fill_parent"android:layout_height="fill_parent"android:id="@+id/capture_evidence_button_capture_evidence"机器人:layout_alignParentBottom =真"android:layout_toRightOf="@+id/capture_evidence_button_cancel"android:layout_toEndOf="@+id/capture_evidence_button_cancel"android:background="@drawable/take_photo_button_camera"android:textSize="25sp"android:textColor="@color/ideality_blanco"android:textStyle="粗体"android:text="@string/capture_evidence_button_capture_evidence"android:paddingBottom="10dp"/></RelativeLayout>

它在 FragmentActivity 下使用(如果你也需要,我可以分享它)

I'm trying to embed a camera preview in an activity. And it's only in portrait orientation. The problem is the preview gets stretched.

I've tried to pick the optimal size. But the problem is all supported preview sizes from getSupportedPreviewSizes() returns sizes in landscape orientation. So picking the right size according to my code won't work I guess.

My layout

<?

Here's my CameraPreview class:

package com.lab.rafael.smartattendance.camera;

import android.content.Context;
import android.hardware.Camera;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import java.io.IOException;
import java.util.List;

public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback {
    private Camera mCamera = null;
    private SurfaceHolder mHolder = null;
    private Camera.Size optimalSize = null;

    public CameraPreview(Context context, Camera camera)
    {
        super(context);
        mCamera = camera;
        mHolder = getHolder();
        mHolder.addCallback(this);
    }

    @Override
    public void surfaceCreated(SurfaceHolder holder) {
        try {
            Camera.Parameters params = mCamera.getParameters();
            List<String> focusModes = params.getSupportedFocusModes();
            mCamera.setDisplayOrientation(90);
            mCamera.setPreviewDisplay(holder);

            if(focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
                params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
            }

            if(optimalSize != null) {
                params.setPreviewSize(optimalSize.width, optimalSize.height);
            }

            mCamera.setParameters(params);

            mCamera.startPreview();
        } catch (IOException e)
        {
            Log.e("created_error", e.getMessage());
        }

    }

    @Override
    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
        if(mHolder.getSurface() == null) {
            return;
        }

        try {
            mCamera.stopPreview();
        } catch (Exception e) {
            Log.e("changed_error", e.getMessage());
        }

        try {
            mCamera.setPreviewDisplay(holder);
            mCamera.startPreview();
        } catch (IOException e){
            Log.e("error", e.getMessage());
        }
    }

    @Override
    public void onMeasure(int measureWidthSpec, int measureHeightSpec) {
        optimalSize = getOptimalSize(MeasureSpec.getSize(measureWidthSpec), MeasureSpec.getSize(measureHeightSpec));
        setMeasuredDimension(optimalSize.width, optimalSize.height);
    }

    protected Camera.Size getOptimalSize(int width, int height) {
        List<Camera.Size> supportedSizes = mCamera.getParameters().getSupportedPreviewSizes();
        double targetRatio = (double) width / height,
                optimalRatio = 0.0,
                acceptableRatioMargin = 0.1,
                minDiff = Double.MAX_VALUE;


        for(Camera.Size size : supportedSizes) {
            optimalRatio = (double) size.width / size.height;
            if(Math.abs(optimalRatio - targetRatio) < acceptableRatioMargin) {
                if(Math.abs(height - size.height) < minDiff) {
                    minDiff = Math.abs(height - size.height);
                    optimalSize = size;
                }
            }
        }

        if(optimalSize == null) {
            for(Camera.Size size : supportedSizes) {
                if(Math.abs(height - size.height) <= minDiff) {
                    minDiff = Math.abs(height - size.height);
                    optimalSize = size;
                }
            }
        }

        return optimalSize;
    }

    public void surfaceDestroyed(SurfaceHolder holder) {
    }
}

The below images is resulting from the values:

Specified resolution from measureSpecWidth/Height = `984x1335`

Returned from getOptimalSize() = `1600x1200`.

Because provided supportedPreviewSizes are for landscape not portrait.

Here's the result:

解决方案

I had same problem like 1 year ago. Plus I had to deal with frontal and back camera. I don't remember much about the code but I tried it before posting this answer an it's still working like a charm.
Hope you can dig and compare with your code. I can share more code if you just something working ;)

/**
 * A simple wrapper around a Camera and a SurfaceView that renders a centered preview of the Camera
 * to the surface. We need to center the SurfaceView because not all devices have cameras that
 * support preview sizes at the same aspect ratio as the device's display.
 */
public class Preview extends ViewGroup implements SurfaceHolder.Callback {

    SurfaceView mSurfaceView;
    SurfaceHolder mHolder;
    Camera.Size mPreviewSize;
    List<Camera.Size> mSupportedPreviewSizes;
    Camera mCamera;
    private Context context;
    private int mCameraId;
    public boolean use_front_camera;

    public Preview(Context context, int cameraId) {
        super(context);

        this.context = context;
        mCameraId = cameraId;
        use_front_camera = true;

        mSurfaceView = new SurfaceView(context);
        addView(mSurfaceView);

        // Install a SurfaceHolder.Callback so we get notified when the
        // underlying surface is created and destroyed.
        mHolder = mSurfaceView.getHolder();
        mHolder.addCallback(this);
    }

    public void setCamera(Camera camera) {
        mCamera = camera;
        if (mCamera != null) {
            mSupportedPreviewSizes = mCamera.getParameters().getSupportedPreviewSizes();
            requestLayout();
        }
    }

    public void switchCamera(Camera camera) {
        setCamera(camera);
        try {
            camera.setPreviewDisplay(mHolder);
        } catch (IOException exception) {
            android.util.Log.e(IdelityConstants.DEBUG_IDELITY_KEY_LOG, "IOException caused by setPreviewDisplay()", exception);
        }
        Camera.Parameters parameters = camera.getParameters();
        parameters.setPreviewSize(mPreviewSize.width, mPreviewSize.height);
        requestLayout();

        camera.setParameters(parameters);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        // We purposely disregard child measurements because act as a
        // wrapper to a SurfaceView that centers the camera preview instead
        // of stretching it.

        int width = MeasureSpec.getSize(widthMeasureSpec);
        int height = MeasureSpec.getSize(heightMeasureSpec);

        //MUST CALL THIS
        setMeasuredDimension(width, height);

        if (mSupportedPreviewSizes != null) {
            mPreviewSize = getOptimalPreviewSize(mSupportedPreviewSizes, width, height);
        }
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        if (changed && getChildCount() > 0) {
            final View child = getChildAt(0);

            final int width = r - l;
            final int height = b - t;

            int previewWidth = width;
            int previewHeight = height;
            if (mPreviewSize != null) {
                /**
                 * Como el calculo se hace con la cámara en modo landscape y luego toca
                 * girar la cámara para que se vea bien, se pasan los valores cambiados.
                 */
                previewWidth = mPreviewSize.height;
                previewHeight = mPreviewSize.width;
            }

            // Center the child SurfaceView within the parent.
            if (width * previewHeight < height * previewWidth) {
                final int scaledChildWidth = previewWidth * height / previewHeight;
                child.layout((width - scaledChildWidth) / 2, 0,
                    (width + scaledChildWidth) / 2, height);
            } else {
                final int scaledChildHeight = previewHeight * width / previewWidth;
                child.layout(0, (height - scaledChildHeight) / 2,
                    width, (height + scaledChildHeight) / 2);
            }
        }
    }

    public void surfaceCreated(SurfaceHolder holder) {
        // The Surface has been created, acquire the camera and tell it where
        // to draw.
        try {
            if (mCamera != null) {
                mCamera.setPreviewDisplay(holder);
            }
        } catch (IOException exception) {
            android.util.Log.e(IdelityConstants.DEBUG_IDELITY_KEY_LOG, "IOException caused by setPreviewDisplay()", exception);
        }
    }

    public void surfaceDestroyed(SurfaceHolder holder) {
        // Surface will be destroyed when we return, so stop the preview.
    //        if (mCamera != null) {
    //            mCamera.stopPreview();
    //        }
    }


    private Camera.Size getOptimalPreviewSize(List<Camera.Size> sizes, int w, int h) {
        final double ASPECT_TOLERANCE = 0.1;
        double targetRatio = (double) w / h;
        if (sizes == null) return null;

        Camera.Size optimalSize = null;
        double minDiff = Double.MAX_VALUE;

        int targetHeight = h;

        // Try to find an size match aspect ratio and size
        for (Camera.Size size : sizes) {
            double ratio = (double) size.width / size.height;
            if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue;
            if (Math.abs(size.height - targetHeight) < minDiff) {
                optimalSize = size;
                minDiff = Math.abs(size.height - targetHeight);
            }
        }

        // Cannot find the one match the aspect ratio, ignore the requirement
        if (optimalSize == null) {
            minDiff = Double.MAX_VALUE;
            for (Camera.Size size : sizes) {
                if (Math.abs(size.height - targetHeight) < minDiff) {
                    optimalSize = size;
                    minDiff = Math.abs(size.height - targetHeight);
                }
            }
        }
        return optimalSize;
    }

    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
        // Now that the size is known, set up the camera parameters and begin
        // the preview.

        if (mCamera == null)
            return;

        Camera.Parameters parameters = mCamera.getParameters();
        parameters.setFlashMode(Camera.Parameters.FLASH_MODE_AUTO);
            parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
        parameters.setJpegQuality(100);
        parameters.setPreviewSize(mPreviewSize.width, mPreviewSize.height);


        List<Camera.Size> sizes = parameters.getSupportedPictureSizes();
        Camera.Size size = sizes.get(0);
        for(int i=0;i<sizes.size();i++)
        {
            if(sizes.get(i).width > size.width)
                size = sizes.get(i);
        }
        parameters.setPictureSize(size.width, size.height);


        requestLayout();


        mCamera.setParameters(parameters);
            mCamera.setDisplayOrientation(getCameraDisplayOrientation((FragmentActivity)context, mCameraId));
        mCamera.startPreview();
    }


    public static int getCameraDisplayOrientation(FragmentActivity activity, int cameraId) {
        Camera.CameraInfo info = new Camera.CameraInfo();

        Camera.getCameraInfo(cameraId, info);
        int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();

        int degrees = 0;
        switch (rotation) {
            case Surface.ROTATION_0: degrees = 0; break;
            case Surface.ROTATION_90: degrees = 90; break;
            case Surface.ROTATION_180: degrees = 180; break;
            case Surface.ROTATION_270: degrees = 270; break;
        }


        int result;
        if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
            result = (info.orientation + degrees) % 360;
            result = (360 - result) % 360;  // compensate the mirror
        }
        else {  // back-facing
            result = (info.orientation - degrees + 360) % 360;
        }

        return result;
    }


    /** A safe way to get an instance of the Camera object. */
    public static Camera getCameraInstance(int cameraIndex){
        Camera c = null;
        try {
            c = Camera.open(cameraIndex); // attempt to get a Camera instance
        }
        catch (Exception e){
            // Camera is not available (in use or does not exist)
            android.util.Log.e(IdelityConstants.ERROR_IDELITY_KEY_LOG, "Camera is not available: " + e.getMessage());
        }
        return c; // returns null if camera is unavailable
    }
}



here is the

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:id="@+id/capture_evidence_linearLayout_camera"
    android:layout_weight="3"
    android:layout_gravity="center_horizontal">


    <FrameLayout
        android:id="@+id/capture_evidence_camera_preview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"/>

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/capture_evidence_default_text_number_evidence"
        android:id="@+id/capture_evidence_textView_value_typed"
        android:textSize="50sp"
        android:textColor="@color/idelity_blanco"
        android:gravity="center_horizontal"
        android:paddingLeft="5dp"
        android:paddingRight="5dp"
        android:background="#d2000000"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:paddingTop="8dp"
        android:paddingBottom="8dp" />
</RelativeLayout>


<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1">

    <net.idelity.idelitymobile.ui.helpers.IdelityButton
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:text="@string/button_back"
        android:id="@+id/capture_evidence_button_cancel"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:background="@drawable/button_gray"
        android:textColor="@color/idelity_blanco"
        android:textSize="20sp"
        android:paddingLeft="40dp"
        android:paddingRight="40dp"
        android:textStyle="bold" />

    <net.idelity.idelitymobile.ui.helpers.IdelityButton
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/capture_evidence_button_capture_evidence"
        android:layout_alignParentBottom="true"
        android:layout_toRightOf="@+id/capture_evidence_button_cancel"
        android:layout_toEndOf="@+id/capture_evidence_button_cancel"
        android:background="@drawable/take_photo_button_camera"
        android:textSize="25sp"
        android:textColor="@color/idelity_blanco"
        android:textStyle="bold"
        android:text="@string/capture_evidence_button_capture_evidence"
        android:paddingBottom="10dp" />
</RelativeLayout>

Its used under an FragmentActivity (I can share it if you need it too)

这篇关于Android - 如何使用相机 getSupportedPreviewSizes() 进行纵向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-21 05:30