android – 我艺术:找不到类:

android – 我艺术:找不到类:,第1张

概述你好,我是这种 Android Studio Error的新手.可能只是一个警告,但我一直面临着找不到课程的问题. 实际上我正在开发Android Camera API应用程序,问题是我的Front Facing Camera Preview是Stretch.它只发生在华为p8 lite等2-3个设备上.当切换到前置摄像头时,设备会拉伸摄像头预览! 我有相机预览类: public class Ca 你好,我是这种 Android Studio Error的新手.可能只是一个警告,但我一直面临着找不到课程的问题.

实际上我正在开发AndroID Camera API应用程序,问题是我的Front Facing Camera PrevIEw是Stretch.它只发生在华为p8 lite等2-3个设备上.当切换到前置摄像头时,设备会拉伸摄像头预览!

我有相机预览类:

public class CameraPrevIEw extends SurfaceVIEw implements SurfaceHolder.Callback {    //Variables de' PrevIEw    private SurfaceHolder mHolder;    private List<Camera.Size> mSupportedPrevIEwSizes;    private Camera.Size mPrevIEwSize;    private int FOCUS_AREA_SIZE=300;    public static Camera prevIEwCamera;    ////////////////////////    //protected LOGGER keys    protected final String EXCEPTION_KEY="xception";    //////////////////////////    public CameraPrevIEw(Context context,Camera camera) {        super(context);        //get the camera        prevIEwCamera = camera;        if(prevIEwCamera!=null){            // supported prevIEw sizes            mSupportedPrevIEwSizes = prevIEwCamera.getParameters().getSupportedPrevIEwSizes();        }        else{            prevIEwCamera=camera;            // supported prevIEw sizes            mSupportedPrevIEwSizes = prevIEwCamera.getParameters().getSupportedPrevIEwSizes();        }        // Install a SurfaceHolder.Callback so we get notifIEd when the        // underlying surface is created and destroyed.        mHolder = getHolder();        mHolder.addCallback(this);        // deprecated setting,but required on AndroID versions prior to 3.0        mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);        setKeepScreenOn(true);        setPrevIEw();    }    @OverrIDe    public voID surfaceCreated(SurfaceHolder surfaceHolder) {        try{            //when the surface is created,we can set the camera to draw images in this surfaceholder            setPrevIEw();            prevIEwCamera.setPrevIEwdisplay(surfaceHolder);            prevIEwCamera.startPrevIEw();            if(CameraActivity.cameraID==1){                prevIEwCamera.setFaceDetectionListener(faceDetectionListener);                prevIEwCamera.startFaceDetection();            }        } catch(Exception exp){            Log.i(EXCEPTION_KEY,"FROM surfaceCreated: "+exp.toString());        }    }    @OverrIDe    public voID surfaceChanged(SurfaceHolder surfaceHolder,int i,int i2,int i3) {        //before changing the application orIEntation,you need to stop the prevIEw,rotate and then start it again        if(mHolder.getSurface() == null)//check if the surface is ready to receive camera data            return;        try{            prevIEwCamera.stopPrevIEw();        } catch (Exception e){            //this will happen when you are trying the camera if it's not running        }        //Now,recreate the camera prevIEw        try{            //set the camera prevIEw on every prevIEw change            setPrevIEw();            //in case the prevIEw is still @R_702_4041@ bingo! Then...//            Camera.Parameters params = prevIEwCamera.getParameters();//            List<Camera.Size> sizes = params.getSupportedPrevIEwSizes();//            Camera.Size optimalSize = PrevIEwSizeParameters.getoptimalPrevIEwSize(sizes,i2,i3);//            params.setPrevIEwSize(optimalSize.wIDth,optimalSize.height);//            prevIEwCamera.setParameters(params);            prevIEwCamera.setPrevIEwdisplay(mHolder);            prevIEwCamera.startPrevIEw();            if(CameraActivity.cameraID==1){                prevIEwCamera.setFaceDetectionListener(faceDetectionListener);                prevIEwCamera.startFaceDetection();            }        } catch(Exception exp){            Log.i(EXCEPTION_KEY,"FROM surfaceChanged: "+exp.toString());        }    }    public voID setPrevIEw(){        try{            //set the focusable true            this.setFocusable(true);            //set the touch able true            this.setFocusableIntouchMode(true);            //set the camera display orIEntation lock            prevIEwCamera.setdisplayOrIEntation(90);            //get the camera parameters            Camera.Parameters parameters = prevIEwCamera.getParameters();            //set the prevIEw size            parameters.setPrevIEwSize(mPrevIEwSize.wIDth,mPrevIEwSize.height);            //set the parameter            prevIEwCamera.setParameters(parameters);        }catch(Exception exp){            Log.i(EXCEPTION_KEY,"FROM setPrevIEw: "+exp.toString());        }    }    @OverrIDe    public voID surfaceDestroyed(SurfaceHolder surfaceHolder) {        //our app has only one screen,so we'll destroy the camera in the surface        //if you are using with more screens,please move this code your activity        try{            //handle in Activity onResume and onPause        }catch(Exception exp){            Log.i(EXCEPTION_KEY,"FROM surfaceDestroyed: "+exp.toString());        }    }    //OverrIDe Methods here    @OverrIDe    protected voID onMeasure(int wIDthMeasureSpec,int heightmeasureSpec) {        try{            final int wIDth = resolveSize(getSuggestedMinimumWIDth(),wIDthMeasureSpec);            final int height = resolveSize(getSuggestedMinimumHeight(),heightmeasureSpec);            setMeasuredDimension(wIDth,height);            if (mSupportedPrevIEwSizes != null) {                mPrevIEwSize = PrevIEwSizeParameters.getoptimalPrevIEwSize(mSupportedPrevIEwSizes,wIDth,height);            }        }catch(Exception exp){            Log.i(EXCEPTION_KEY,"FROM onMeasure: "+exp.toString());        }    }    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////    private voID stopPrevIEwAndFreeCamera() {        if (prevIEwCamera != null) {            // Call stopPrevIEw() to stop updating the prevIEw surface.            prevIEwCamera.stopPrevIEw();            // important: Call release() to release the camera for use by other            // applications. Applications should release the camera immediately            // during onPause() and re-open() it during onResume()).            prevIEwCamera.release();            prevIEwCamera = null;        }    }    //end of outer class here}

自从过去几天以来,我一直在解决这个问题,并在我的自定义相机预览中获得相同的拉伸效果.

所以我获得最佳预览尺寸的方法是:

public class PrevIEwSizeParameters {    //protected LOGGER keys    protected static final String EXCEPTION_KEY = "xception";    //////////////////////////    public static Camera.Size getoptimalPrevIEwSize(List<Camera.Size> sizes,int w,int h) {        final double ASPECT_TolERANCE = 0.1;        double targetRatio = (double) h / w;        if (sizes == null) return null;        Camera.Size optimalSize = null;        double minDiff = Double.MAX_VALUE;        int targetHeight = h;        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);            }        }        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;    }}

问题

问题是只在前置摄像头上拉伸摄像头预览.我的日志cat数据如下:

它显示了一些行开头:I / art:找不到类:因为我是新手,所以我不知道它们是什么意思?

解决方法 确保将以下依赖项添加到应用程序build.gradle文件中.
compile 'com.androID.support:appcompat-v7:24.1.1'compile 'com.androID.support:recyclervIEw-v7:24.1.1'

从屏幕截图中,可以在recyclervIEw支持库(DefaultItemAnimator和SimpleItemAnimator)中找到这些缺失的类.

总结

以上是内存溢出为你收集整理的android – 我/艺术:找不到类:全部内容,希望文章能够帮你解决android – 我/艺术:找不到类:所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1135677.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存