title: Android - how to set margin relative to another control?
body: <p>I'm really new to android and would appreciate any help from you.
  I have a screen with different templates for two kind of products. Each template is a separate xml file where I place a bunch of controls. Every control has it's own exact place in the screen which I define with margins.
  The problem is I don't know how long is going to be a text in the upper TextView. If there is a one line everything looks fine, but a few lines destroy it. 
  Is there any way to stretch upper textview and at the same time keep all the rest controls relative to this textview?
  The code is:</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="fill_parent"
      android:layout_height="fill_parent"
      android:background="@color/regBackground"
      android:orientation="vertical" &gt;
  
      &lt;FrameLayout
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:background="@color/regBackground" &gt;
  
          &lt;TextView
              android:id="@+id/txtProductNameScreenD"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="right"
              android:layout_marginLeft="10dp"
              android:layout_marginRight="18dp"
              android:layout_marginTop="10dp"
              android:text="@string/empty"
              android:textColor="@color/_black"
              android:textSize="16sp"
              android:textStyle="bold"
              android:lines="1"
              android:ellipsize="end"
              android:scrollHorizontally="true"
              android:singleLine="true" &gt;
          &lt;/TextView&gt;
  
          &lt;ImageView
              android:id="@+id/imgProductBcgD"
              android:layout_width="300dp"
              android:layout_height="263dp"
              android:layout_gravity="center_horizontal"
              android:layout_marginTop="40dp"
              android:src="@drawable/frame_product_screen" &gt;
          &lt;/ImageView&gt;
  
          &lt;ImageView
              android:id="@+id/imgProductScreenD"
              android:layout_width="250dp"
              android:layout_height="260dp"
              android:layout_gravity="center_horizontal"
              android:layout_marginTop="42dp"
              android:background="@color/_white" &gt;
          &lt;/ImageView&gt;
  
          &lt;ImageView
              android:id="@+id/imgProductScreendiscD"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="top|center"
              android:layout_marginTop="205dp"
              android:src="@drawable/discount_bkg_product_screen" &gt;
          &lt;/ImageView&gt;
  
          &lt;TextView
              android:id="@+id/txtProdScreenPrice"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="right|top"
              android:layout_marginRight="45dp"
              android:layout_marginTop="220dp"
              android:ellipsize="end"
              android:lines="1"
              android:scrollHorizontally="true"
              android:singleLine="true"
              android:text="@string/empty"
              android:textColor="@color/_black"
              android:textSize="18sp" &gt;
          &lt;/TextView&gt;
  
          &lt;TextView
              android:id="@+id/txtPriceShekelD1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="right|top"
              android:layout_marginRight="80dp"
              android:layout_marginTop="230dp"
              android:ellipsize="end"
              android:lines="1"
              android:scrollHorizontally="true"
              android:singleLine="true"
              android:text="@string/shekel_symbol"
              android:textColor="@color/_gray"
              android:textSize="10sp" /&gt;
  
          &lt;TextView
              android:id="@+id/txtBeforeDiscD"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="right|top"
              android:layout_marginRight="25dp"
              android:layout_marginTop="237dp"
              android:ellipsize="end"
              android:lines="1"
              android:scrollHorizontally="true"
              android:singleLine="true"
              android:text="@string/before_discount"
              android:textColor="@color/_gray"
              android:textSize="10sp" /&gt;
  
          &lt;TextView
              android:id="@+id/txtProdScreenDiscount"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="right|top"
              android:layout_marginRight="140dp"
              android:layout_marginTop="220dp"
              android:ellipsize="end"
              android:lines="1"
              android:scrollHorizontally="true"
              android:singleLine="true"
              android:text="@string/empty"
              android:textColor="@color/_orange"
              android:textSize="18sp" &gt;
          &lt;/TextView&gt;
  
          &lt;TextView
              android:id="@+id/txtDiscountD"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="right|top"
              android:layout_marginRight="145dp"
              android:layout_marginTop="237dp"
              android:ellipsize="end"
              android:lines="1"
              android:scrollHorizontally="true"
              android:singleLine="true"
              android:text="@string/bonus"
              android:textColor="@color/_gray"
              android:textSize="10sp" /&gt;
  
          &lt;TextView
              android:id="@+id/txtProdScreenDiscountPrice"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="left|top"
              android:layout_marginLeft="45dp"
              android:layout_marginTop="220dp"
              android:ellipsize="end"
              android:lines="1"
              android:scrollHorizontally="true"
              android:singleLine="true"
              android:text="@string/empty"
              android:textColor="@color/_black"
              android:textSize="18sp" &gt;
          &lt;/TextView&gt;
  
          &lt;TextView
              android:id="@+id/txtPriceShekelD2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="left|top"
              android:layout_marginLeft="30dp"
              android:layout_marginTop="230dp"
              android:ellipsize="end"
              android:lines="1"
              android:scrollHorizontally="true"
              android:singleLine="true"
              android:text="@string/shekel_symbol"
              android:textColor="@color/_gray"
              android:textSize="10sp" /&gt;
  
          &lt;TextView
              android:id="@+id/txtAfterDiscD"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="left|top"
              android:layout_marginLeft="30dp"
              android:layout_marginTop="237dp"
              android:ellipsize="end"
              android:lines="1"
              android:scrollHorizontally="true"
              android:singleLine="true"
              android:text="@string/after_discount"
              android:textColor="@color/_gray"
              android:textSize="10sp" /&gt;
  
          &lt;Button
              android:id="@+id/btnShareFacebookD"
              android:layout_width="300dp"
              android:layout_height="wrap_content"
              android:layout_gravity="center_horizontal"
              android:layout_marginTop="255dp"
              android:background="@drawable/facebook_button_product_screen" &gt;
          &lt;/Button&gt;
  
          &lt;TextView
              android:id="@+id/txtDatePSDiscD"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="right|center_horizontal"
              android:layout_marginRight="90dp"
              android:layout_marginTop="315dp"
              android:text="@string/exp_date"
              android:textColor="@color/_gray"
              android:textSize="14sp" &gt;
          &lt;/TextView&gt;
  
          &lt;TextView
              android:id="@+id/txtDateProductScreenD"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="left|center_horizontal"
              android:layout_marginLeft="90dp"
              android:layout_marginTop="315dp"
              android:text="@string/empty"
              android:textColor="@color/_blue"
              android:textSize="14sp" &gt;
          &lt;/TextView&gt;
  
          &lt;ImageView
              android:id="@+id/imgSeparatorProductScreenD"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center_horizontal"
              android:layout_marginTop="345dp"
              android:src="@drawable/separator_product_screen" &gt;
          &lt;/ImageView&gt;
  
          &lt;TextView
              android:id="@+id/txtDescriptionProductScreenD"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="right"
              android:layout_marginLeft="20dp"
              android:layout_marginRight="20dp"
              android:layout_marginTop="355dp"
              android:inputType="textMultiLine"
              android:text="@string/empty"
              android:textColor="@color/_black"
              android:textSize="12sp" &gt;
          &lt;/TextView&gt;
      &lt;/FrameLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>