title: Is there a way to offset a view from center?
body: <p>I'm trying to possition my button not exactly in center, but let's say in the 2/5s of the screen height, I was looking for attribute unsuccessfully, so I tried this approach</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@drawable/background"
  android:padding="20dp" &gt;
  
   &lt;ImageButton
      android:id="@+id/flashlight_button"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_above="@+id/fakeView"
      android:background="@null"
      android:contentDescription="@string/flashlight_button_description"
      android:src="@drawable/freeml_bright" /&gt;
  
     &lt;View
      android:id="@+id/fakeView"
      android:layout_width="10dp"
      android:layout_height="10dp"
      android:layout_centerInParent="true"
      android:background="#FFAABB" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>However it does not work, even if I set margin on the fake view.</p>
  
  <p>Padding attribute works, however as it is a big image and if I want it to start at 2/5ths of screen height, it covers the center point of screen, so if I use padding attribute it works but it pushes it away from center and does not allow it to cover it.</p>
  
  <p>Alhough, I made it work using <code>LinearLayout</code>, which I wanted to avoid because there are more Views on top and bottom next to each other so it would lead to nested views using linear layout. Unfortunately I think its the only option.</p>
  
  <p>It basically it uses another linear layout that fills the remaining space left unused by top and bottom views with <code>height=0dp</code> and <code>weight=1</code> and sets its gravity to center.</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="vertical"
  android:padding="20dp"&gt;
  
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal"
      android:gravity="center" &gt;
  
      &lt;ImageView
          android:id="@+id/imageView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:contentDescription="@string/application_logo_description"
          android:src="@drawable/mylight" /&gt;
  
       &lt;ImageButton
          android:id="@+id/settings_button"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="right"
          android:background="@null"
          android:contentDescription="@string/settings_button_description"
          android:src="@drawable/settings_button" /&gt; 
  &lt;/LinearLayout&gt;
  
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:layout_weight="1"
      android:gravity="center"
      android:orientation="vertical" &gt;
  
      &lt;ImageButton
          android:id="@+id/flashlight_button"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:background="@null"
          android:contentDescription="@string/flashlight_button_description"
          android:src="@drawable/flashlight_button_selector" /&gt;
  
      &lt;View
          android:id="@+id/fakeView"
          android:layout_width="0dp"
          android:layout_height="0dp"
          android:layout_marginTop="60dp"
          android:background="#FFAABB" /&gt;
  &lt;/LinearLayout&gt;
  
  &lt;ImageView
      android:id="@+id/imageView2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="bottom|center_horizontal"
      android:contentDescription="@string/powered_by_description"
      android:src="@drawable/powered_by" /&gt;
  
  &lt;ImageButton
      android:id="@+id/ad_button"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="bottom|center_horizontal"
      android:background="@null"
      android:contentDescription="@string/ad_button_description"
      android:src="@drawable/freeml" /&gt;
  
   &lt;/LinearLayout&gt;
  </code></pre>