I'm trying to put an horizontal LinearLayout (with code) into a vertical LinearLayout(which is actually on the xml file). Well, when I do that, it seems like it doesn't create the horizontal Linear, I post my code and an image:
MyCameraActivity
    package com.example.android.navigationdrawer;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
public class MyCameraActivity extends AppCompatActivity {
    private static final int CAMERA_REQUEST = 1888;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.content_my_camera);
        ImageView photoButton = (ImageView) this.findViewById(R.id.button1);
        //OnClick camera button
        photoButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                startActivityForResult(cameraIntent, CAMERA_REQUEST);
            }
        });
    }
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
            //Cast LinearLayout of .xml
            LinearLayout CamaraLayout = (LinearLayout) findViewById(R.id.CameraLayout);
            //Get rotation
            int rotation =  getWindowManager().getDefaultDisplay().getRotation();
            //Number of photos
            int PhotoNumber = 0;
            //CREATE LINEAR LAYOUT
            LinearLayout LL = new LinearLayout(this);
            LL.setOrientation(LinearLayout.HORIZONTAL);
            LinearLayout.LayoutParams LLParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            LL.setLayoutParams(LLParams);
            int angle = 0;
            switch (rotation) {
                case Surface.ROTATION_90:
                    angle = -90;
                    PhotoNumber = PhotoNumber+1;
                    if (PhotoNumber == 6) {
                        //Set LinearLayout params
                        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                        lp.setMargins(0, 5, 7, 5);
                        //Create imageView to put Bitmap
                        ImageView imageView = new ImageView(this);
                        //Put LayoutParams
                        imageView.setLayoutParams(lp);
                        //Adding the Bitmap
                        Bitmap photo = (Bitmap) data.getExtras().get("data");
                        imageView.setImageBitmap(photo);
                        //Add image to Linear Layout
                        LL.addView(imageView);
                        //Add the Linear Layout  to "CamaraLayout"
                        CamaraLayout.addView(LL);
                    } else {
                        //Set LinearLayout params
                        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                        lp.setMargins(7, 5, 7, 5);
                        //Create imageView to put Bitmap
                        ImageView imageView = new ImageView(this);
                        //Put LayoutParams
                        imageView.setLayoutParams(lp);
                        //Adding the Bitmap
                        Bitmap photo = (Bitmap) data.getExtras().get("data");
                        imageView.setImageBitmap(photo);
                        //Add image to Linear Layout
                        CamaraLayout.addView(imageView);
                    }
                    break;
                case Surface.ROTATION_180:
                    angle = 180;
                    PhotoNumber = PhotoNumber+1;
                    if (PhotoNumber == 4) {
                        //Set LinearLayout params
                        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                        lp.setMargins(0, 5, 7, 5);
                        //Create imageView to put Bitmap
                        ImageView imageView = new ImageView(this);
                        //Put LayoutParams
                        imageView.setLayoutParams(lp);
                        //Adding the Bitmap
                        Bitmap photo = (Bitmap) data.getExtras().get("data");
                        imageView.setImageBitmap(photo);
                        //Add image to Linear Layout
                        LL.addView(imageView);
                        //Add the Linear Layout  to "CamaraLayout"
                        CamaraLayout.addView(LL);
                    } else {
                        //Set LinearLayout params
                        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                        lp.setMargins(7, 5, 7, 5);
                        //Create imageView to put Bitmap
                        ImageView imageView = new ImageView(this);
                        //Put LayoutParams
                        imageView.setLayoutParams(lp);
                        //Adding the Bitmap
                        Bitmap photo = (Bitmap) data.getExtras().get("data");
                        imageView.setImageBitmap(photo);
                        //Add image to Linear Layout
                        CamaraLayout.addView(imageView);
                    }
                    break;
                case Surface.ROTATION_270:
                    angle = 90;
                    PhotoNumber = PhotoNumber+1;
                    if (PhotoNumber == 6) {
                        //Set LinearLayout params
                        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                        lp.setMargins(0, 5, 7, 5);
                        //Create imageView to put Bitmap
                        ImageView imageView = new ImageView(this);
                        //Put LayoutParams
                        imageView.setLayoutParams(lp);
                        //Adding the Bitmap
                        Bitmap photo = (Bitmap) data.getExtras().get("data");
                        imageView.setImageBitmap(photo);
                        //Add image to Linear Layout
                        LL.addView(imageView);
                        //Add the Linear Layout  to "CamaraLayout"
                        CamaraLayout.addView(LL);
                    } else {
                        //Set LinearLayout params
                        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                        lp.setMargins(7, 5, 7, 5);
                        //Create imageView to put Bitmap
                        ImageView imageView = new ImageView(this);
                        //Put LayoutParams
                        imageView.setLayoutParams(lp);
                        //Adding the Bitmap
                        Bitmap photo = (Bitmap) data.getExtras().get("data");
                        imageView.setImageBitmap(photo);
                        //Add image to Linear Layout
                        CamaraLayout.addView(imageView);
                    }
                    break;
                default:
                    angle = 0;
                    PhotoNumber = PhotoNumber+1;
                    if (PhotoNumber == 4) {
                        //Set LinearLayout params
                        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                        lp.setMargins(0, 5, 7, 5);
                        //Create imageView to put Bitmap
                        ImageView imageView = new ImageView(this);
                        //Put LayoutParams
                        imageView.setLayoutParams(lp);
                        //Adding the Bitmap
                        Bitmap photo = (Bitmap) data.getExtras().get("data");
                        imageView.setImageBitmap(photo);
                        //Add image to Linear Layout
                        LL.addView(imageView);
                        //Add the Linear Layout  to "CamaraLayout"
                        CamaraLayout.addView(LL);
                    } else {
                        //Set LinearLayout params
                        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                        lp.setMargins(7, 5, 7, 5);
                        //Create imageView to put Bitmap
                        ImageView imageView = new ImageView(this);
                        //Put LayoutParams
                        imageView.setLayoutParams(lp);
                        //Adding the Bitmap
                        Bitmap photo = (Bitmap) data.getExtras().get("data");
                        imageView.setImageBitmap(photo);
                        //Add image to Linear Layout
                        CamaraLayout.addView(imageView);
                    }
                    break;
            }
        }
    }
}
I don't post the .xml, because it's only a LinearLayout and an ImageView.
And I want the images to be displayed one next to each other.
Some of you may have thought the idea of directly making an horizontal LinearLayout, and that works, but I'm working on a program that puts different "lines" of photos.
Any idea? thanks!