Android SurfaceView - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android SurfaceView class.

This code example shows how to use the following methods: getHolder, setLayoutParams
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getHolder, setFocusable, setFocusableInTouchMode, setOnTouchListener
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		mPreview = new SurfaceView(this);
		setContentView(mPreview);
		 
		init(); 
		 
		initViews(); 
	} 
	 
	private void initViews() { 
		mPreview.setFocusable(true);
		mPreview.setFocusableInTouchMode(true);
		mPreview.setOnTouchListener(this);
		 
		/* 得到SurfaceHolder对象 */ 
		mHolder = mPreview.getHolder();

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getHolder
 
        mCamera = camera;
 
        // Install a SurfaceHolder.Callback so we get notified when the 
        // underlying surface is created and destroyed. 
        mHolder = mSurfaceView.getHolder();
        mHolder.addCallback(this);
        mHolder.setSizeFromLayout();
        mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    } 
     
    public void stopPreview() { 
        Logger.T(TAG, "stopPreview");
        if (mCamera != null) {
            mCamera.stopPreview();
            mCamera = null;
        } else { 
            Logger.T(TAG, "No camera to stop preview");
        } 
    } 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getHolder
	private FeatureStreamer fs;
 
	FeatureStreamingCameraPreview(Context context, FeatureStreamer fs) {
		super(context);
		this.fs = fs;
		mSurfaceView = new SurfaceView(context);
		addView(mSurfaceView);
 
		mHolder = mSurfaceView.getHolder();
		mHolder.addCallback(this);
		mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
	} 
 
	public void updateAccelerometerFeatures(float[] features) {
		synchronized (this) {
		  accelerometerFeatures = features;
		} 
	} 
	 
	public void setCamera(Camera camera) {
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setEGLConfigChooser, setRenderer, getHolder
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        // Create our Preview view and set it as the content of our 
        // Activity 
        mGLSurfaceView = new GLSurfaceView(this);
        // We want an 8888 pixel format because that's required for 
        // a translucent window. 
        // And we want a depth buffer. 
        mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
        // Tell the cube renderer that we want to render a translucent version 
        // of the cube: 
        mGLSurfaceView.setRenderer(new CubeRenderer(true));
        // Use a surface format with an Alpha channel: 
        mGLSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
        setContentView(mGLSurfaceView);
    } 
 
    @Override 
    protected void onResume() { 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android SurfaceView Questions & Answers:

See Code Examples for Android SurfaceView Methods: