title: layout_weight for both horizontal and vertical
body: <p>I have a situation like this:</p>
  
  <p><img src="https://i.stack.imgur.com/KwDJo.jpg" alt="Sample app"></p>
  
  <p>I have layout like this:</p>
  
  <pre><code>&lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal" &gt;
  
      &lt;RelativeLayout
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_weight="0.6" &gt;
  
          &lt;!-- using relativelayout I can match background size to content --&gt;
  
          &lt;View
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignBottom="@id/riderTable"
              android:layout_alignLeft="@id/riderTable"
              android:layout_alignRight="@id/riderTable"
              android:layout_alignTop="@+id/riderTable"
              android:background="@drawable/rider_opisowe" /&gt;
  
          &lt;TableLayout
              android:id="@+id/riderTable"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:padding="2dp"
              android:shrinkColumns="*" &gt;
  
              &lt;TableRow
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content" &gt;
  
                  &lt;!-- TextViews here --&gt;
              &lt;/TableRow&gt;
              &lt;!-- more rows --&gt;
  
          &lt;/TableLayout&gt;
      &lt;/RelativeLayout&gt;
  
      &lt;ImageView
          android:id="@+id/imgPhoto"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_gravity="top"
          android:layout_weight="0.4"
          android:adjustViewBounds="true"
          android:src="@drawable/myImage" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And 60%/40% ratio is working, however imageview (white square) is not matching blue box height. I want the image container to have width of 40% of parent's, the same height as blue box and contain image.</p>
  
  <p>Already tried this: <a href="https://stackoverflow.com/questions/17561404/trying-to-get-android-linearlayout-to-stretch-horizontally-and-vertically">Trying to get Android LinearLayout to stretch horizontally and vertically</a>
  However simple example described there is just using one-color backgrounds, if I switch to images this is not working as expected. So putting it inside another linearLayout does not solve the problem.</p>
  
  <p>Any help will be appreciated.</p>