Code example for FrameLayout

Methods: addView

0
 
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        FrameLayout content = new FrameLayout(this);
 
        mTextureView = new TextureView(this);
        mTextureView.setSurfaceTextureListener(this);
 
        Button button = new Button(this);
        button.setText("Copy bitmap to /sdcard/textureview.png");
        button.setOnClickListener(new View.OnClickListener() {
            @Override 
            public void onClick(View v) {
                Bitmap b = mTextureView.getBitmap();
                try { 
                    FileOutputStream out = new FileOutputStream(
                            Environment.getExternalStorageDirectory() + "/textureview.png");
                    try { 
                        b.compress(Bitmap.CompressFormat.PNG, 100, out);
                    } finally { 
                        try { 
                            out.close();
                        } catch (IOException e) {
                            // Ignore 
                        } 
                    } 
                } catch (FileNotFoundException e) {
                    // Ignore 
                } 
            } 
        }); 
 
        content.addView(mTextureView, new FrameLayout.LayoutParams(500, 400, Gravity.CENTER));
        content.addView(button, new FrameLayout.LayoutParams(
                FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT,
                Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM));
        setContentView(content);
    } 
 
Connect your IDE to all the code out there  Get Codota for Java