I want to have some views disposed like in the following image:
and God knows I have tried several ways to achieve it, none of them really working.
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.
The xml of this attempt is the following.
audio_player.xml:
<?xml version="1.0" encoding="utf-8"?>
<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" >
<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" />
<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" />
<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="+" />
<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="-" />
<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" />
<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" />
<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" />
<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" />
</RelativeLayout>
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. :(
Heeeelp!
EDIT:
That layout is inside another layout. I post the most interesting part of it:
<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" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/backround" >
<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" />
<include
android:id="@+id/audio_player"
android:layout_width="match_parent"
android:layout_height="match_parent"
layout="@layout/audio_player" />
</RelativeLayout>
</com.slidinglayer.SlidingLayer>