title: Center a group of views horizontally
body: <p>I want to have some views disposed like in the following image:</p>
  
  <p><img src="https://i.stack.imgur.com/ULjab.png" alt="Disposition of elements"></p>
  
  <p>and God knows I have tried several ways to achieve it, none of them really working.</p>
  
  <p>In this last attempt, the layout looks as it should be, but I just found out that the padding becomes part of the clickable part of the view and, therefore, the Stop button canibalizes the Start button, and this one does not work.</p>
  
  <p>The xml of this attempt is the following.</p>
  
  <p>audio_player.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &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:padding="@dimen/activity_horizontal_margin" &gt;
  
  &lt;ImageView
      android:id="@+id/pauseButton"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:onClick="pauseAudio"
      android:paddingRight="70dp"
      android:src="@drawable/pause_selector"
      android:text="PAUSE"
      android:visibility="invisible" /&gt;
  
  &lt;ImageView
      android:id="@+id/playButton"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:onClick="playSelection"
      android:paddingRight="70dp"
      android:src="@drawable/play_selector"
      android:text="PLAY" /&gt;
  
  &lt;ImageView
      android:id="@+id/moreVolumeButton"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignBottom="@+id/stopButton"
      android:layout_toRightOf="@+id/stopButton"
      android:onClick="adjustVolume"
      android:paddingLeft="15dp"
      android:src="@drawable/volume_plus_selector"
      android:text="+" /&gt;
  
  &lt;ImageView
      android:id="@+id/lessVolumeButton"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignBottom="@+id/playButton"
      android:layout_toLeftOf="@+id/playButton"
      android:onClick="adjustVolume"
      android:paddingRight="15dp"
      android:src="@drawable/volume_minus_selector"
      android:text="-" /&gt;
  
  &lt;ImageView
      android:id="@+id/stopButton"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:onClick="stopAudio"
      android:paddingLeft="70dp"
      android:src="@drawable/stop_selector"
      android:text="STOP" /&gt;
  
  &lt;SeekBar
      android:id="@+id/seekBarPlayer"
      android:layout_width="180dp"
      android:layout_height="wrap_content"
      android:layout_below="@id/stopButton"
      android:layout_centerHorizontal="true"
      android:paddingTop="5dp"
      android:src="@drawable/process_bar" /&gt;
  
  &lt;TextView
      android:id="@+id/audioTotalTime"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignBottom="@+id/seekBarPlayer"
      android:layout_toRightOf="@+id/seekBarPlayer"
      android:paddingBottom="6dp"
      android:paddingLeft="7dp"
      android:text="@string/initial_time"
      android:textAppearance="?android:attr/textAppearanceSmall" /&gt;
  
  &lt;TextView
      android:id="@+id/audioRunningTime"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignBottom="@+id/seekBarPlayer"
      android:layout_toLeftOf="@+id/seekBarPlayer"
      android:paddingBottom="6dp"
      android:paddingRight="7dp"
      android:text="@string/initial_time"
      android:textAppearance="?android:attr/textAppearanceSmall" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>I am sure there needs to be a better way of doing it, I thought of grouping the upper elements into a RelativeLayout and apply to it the android:layout_centerHorizontal="true" but it did not work. :(</p>
  
  <p>Heeeelp!</p>
  
  <p>EDIT:</p>
  
  <p>That layout is inside another layout. I post the most interesting part of it:</p>
  
  <pre><code>&lt;com.slidinglayer.SlidingLayer
      xmlns:slidingLayer="http://schemas.android.com/apk/res/------------"
      android:id="@+id/slidingLayer2"
      android:layout_width="@dimen/layer_width"
      android:layout_height="match_parent"
      slidingLayer:closeOnTapEnabled="false"
      slidingLayer:offsetWidth="@dimen/offset_width" &gt;
  
      &lt;RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@drawable/backround" &gt;
  
          &lt;android.inputmethodservice.KeyboardView
              android:id="@+id/keyboardview2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentBottom="true"
              android:layout_centerHorizontal="true"
              android:background="#00000000"
              android:focusable="true"
              android:focusableInTouchMode="true"
              android:keyBackground="@drawable/keyboard_button_selector"
              android:paddingBottom="@dimen/activity_horizontal_margin"
              android:visibility="gone" /&gt;
  
          &lt;include
              android:id="@+id/audio_player"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              layout="@layout/audio_player" /&gt;
      &lt;/RelativeLayout&gt;
  &lt;/com.slidinglayer.SlidingLayer&gt;
  </code></pre>