Why my 2 custom view layouts are overlapping each others although I'm using LinearLayout
<p>I try to add to custom views during runtime.</p>

<h2>MainActivity.java</h2>

<pre><code>package com.example.bug;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        android.view.ViewGroup root = (android.view.ViewGroup)getWindow().getDecorView().findViewById(android.R.id.content);
        View v0 = this.getLayoutInflater().inflate(R.layout.custom_view, null);
        View v1 = this.getLayoutInflater().inflate(R.layout.custom_view, null);
        ((android.widget.TextView)v0.findViewById(R.id.textView1)).setText("Text view 1");
        ((android.widget.TextView)v1.findViewById(R.id.textView1)).setText("Text view 2");
        // I expect v1 will below v0 as we are using vertical LinearLayout.
        // However, they are overlapping each others.
        root.addView(v0);
        root.addView(v1);
    }
}
</code></pre>

<h2>custom_view.xml</h2>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:orientation="horizontal" &gt;

    &lt;TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge" /&gt;

    &lt;EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10" &gt;
    &lt;/EditText&gt;

&lt;/LinearLayout&gt;
</code></pre>

<h2>activity_main.xml</h2>

<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" &gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>However, I do not understand. I expect the 2nd view will on the bottom of 1st view. However, I'm getting overlapping result.</p>

<h2>(Do it through Java way)</h2>

<p><img src="http://i.stack.imgur.com/905DJ.png" alt="enter image description here"></p>

<p>Is there any steps I had done wrongly? Thank you.</p>

<p>Note, thing works fine if I add the 2 custom views through XML way instead of Java. But I still do not understand why my Java way doesn't work?</p>

<h2>activity_main.xml</h2>

<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" &gt;
    &lt;include layout="@layout/custom_view"/&gt;
    &lt;include layout="@layout/custom_view"/&gt;
&lt;/LinearLayout&gt;
</code></pre>

<h2>(Do it through XML way)</h2>

<p><img src="http://i.stack.imgur.com/LD8Iq.png" alt="enter image description here"></p>
