title: LinearLayout weight does not work in DialogFragment
body: <p>I have a custom view which is basically simply to show some info for a transaction, this is the layout:</p>
  
  <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="match_parent"
      android:orientation="horizontal"
      android:background="#a8d1ff"
      android:weightSum="8"&gt;
  
      &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="0dp"
          android:layout_height="match_parent"
          android:layout_weight="2"
          android:orientation="vertical"
          android:weightSum="6"&gt;
  
          &lt;FrameLayout
              android:id="@+id/leftPartRowOneRelativeLayout"
              android:layout_width="match_parent"
              android:layout_height="0dp"
              android:layout_weight="3"&gt;
  
              &lt;ImageView
                  android:id="@+id/nzNumberImageView"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:adjustViewBounds="true"
                  android:scaleType="fitXY"
                  android:src="@drawable/transaction_view_leftupside_nz_test" /&gt;
  
              &lt;TextView
                  android:id="@+id/nzNumberTextView"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:gravity="right"
                  android:text="18"
                  android:textSize="40dp" /&gt;
          &lt;/FrameLayout&gt;
  
          &lt;ImageView
              android:id="@+id/productNumberImageView"
              android:layout_width="match_parent"
              android:layout_height="0dp"
              android:layout_weight="3"
              android:adjustViewBounds="true"
              android:scaleType="fitXY"
              android:src="@drawable/transaction_view_leftdownside_product_test" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/trx_summary_LinearLayout"
          android:layout_width="0dp"
          android:layout_height="match_parent"
          android:layout_weight="6"
          android:weightSum="10"
          android:orientation="vertical"&gt;
          &lt;TextView
              android:layout_width="match_parent"
              android:layout_height="0dp"
              android:layout_weight="3"
              android:textSize="20dp"
              android:textColor="#FF000000"
              android:id="@+id/palceHolder0" android:text="testRow0"/&gt;
          &lt;TextView
              android:layout_width="match_parent"
              android:layout_height="0dp"
              android:layout_weight="3"
              android:textSize="20dp"
              android:textColor="#FF000000"
              android:id="@+id/palceHolder1" android:text="testRow1"/&gt;
          &lt;TextView
              android:layout_width="match_parent"
              android:layout_height="0dp"
              android:layout_weight="4"
              android:textSize="20dp"
              android:textColor="#FF000000"
              android:id="@+id/palceHolder2" android:text="testRow2"/&gt;
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>This it what it looks like in Android Studio <strong>preview</strong>, and it did meet my expectation (left and right divide the full parent container with <strong>ratio 2:6</strong>):</p>
  
  <p><a href="https://i.stack.imgur.com/SLKOS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SLKOS.png" alt="looks good"></a></p>
  
  <p>Later, this view will be shown in a <code>DialogFragment</code>,
  and this is the <code>onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)</code> for <code>DialogFragment</code>:</p>
  
  <pre><code>MyView mv = new MyView(getActivity().getBaseContext());
  mv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
  return mv;
  </code></pre>
  
  <p>But now, the <strong>weight of 2:6</strong> seems <strong>not</strong> working any more in pop up <code>Dialog</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/PnJus.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PnJus.png" alt="not good"></a></p>
  
  <p>I'm using Android 6. </p>
  
  <p>Can anyone help?</p>
  
  <p>[edit0]:
  I want the <code>Dialog</code> show as screen width, but half screen height, so I put this code in <code>MyDialogFragment</code>:</p>
  
  <pre><code>@Override
  public void onResume() {
      ViewGroup.LayoutParams params = getDialog().getWindow().getAttributes();
      params.width = ViewGroup.LayoutParams.MATCH_PARENT;
      params.height = this.height;
      getDialog().getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
      super.onResume();
  }
  </code></pre>
  
  <p>that <code>this.height</code> is passed in by <code>bundle</code> which is the <code>screen height/2</code>.</p>