I have a couple of views that I'm trying to center over each other but at the same position at the top of the view. pw_futuretabata is a progresswheel that I want to be as big as the screen width and aligned to the top of the screen. Inside the progresswheel, I have a smaller version, pw_spinner, that I will initially show. I want to place an image, playButton, inside pw_spinner. I've created a view called horizontalCenterLine to find the center location within this contained view and am trying to place playButton just above the horizontal center.
If I do this with everything being centered in the root view, all is fine, but because I need this group of controls aligned to the top of the screen, I placed them in their own RelativeLayout and positioned the relative layout to align to the top of the parent.
So now my problem is, playButton, as it is, doesn't display where I expect it. Instead, the bottom of the button is aligned to the top of the screen, so only the bottom pixels of the button are visible. I don't understand why. If I change the button to be centered with
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
it works fine and is centered in pw_spinner, but using
android:layout_alignBottom="@id/horizontalCenterLine"
android:layout_centerHorizontal="true"
is not giving me what I'm looking for. Any ideas?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ProgressWheel="http://schemas.android.com/apk/res-auto"
android:id="@+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<RelativeLayout
android:id="@+id/internalLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" >
<com.todddavies.components.ProgressWheel
android:id="@+id/pw_futuretabata"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
ProgressWheel:barColor="#FCEC5A"
ProgressWheel:barLength="60dp"
ProgressWheel:barWidth="10dp"
ProgressWheel:delayMillis="75"
ProgressWheel:rimColor="#343434"
ProgressWheel:rimWidth="10dp"
ProgressWheel:spinSpeed="30dp"
ProgressWheel:textColor="#FCEC5A"
ProgressWheel:textSize="60sp"
android:visibility="invisible" />
<com.todddavies.components.ProgressWheel
android:id="@+id/pw_spinner"
android:layout_width="165dp"
android:layout_height="165dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
ProgressWheel:barColor="#FCEC5A"
ProgressWheel:barLength="60dp"
ProgressWheel:barWidth="5dp"
ProgressWheel:delayMillis="75"
ProgressWheel:rimColor="#343434"
ProgressWheel:rimWidth="5dp"
ProgressWheel:spinSpeed="30dp"
ProgressWheel:textColor="#FCEC5A"
ProgressWheel:textSize="60sp" />
<View
android:id="@+id/horizontalCenterLine"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@android:color/darker_gray"
android:visibility="invisible" />
<ImageButton
android:id="@+id/playButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/horizontalCenterLine"
android:layout_centerHorizontal="true"
android:background="@android:color/transparent"
android:contentDescription="@string/playButtonLabel"
android:src="@drawable/shape_play" />
</RelativeLayout>
<ImageView
android:id="@+id/myIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:contentDescription="@string/app_icon_description"
android:src="@drawable/pp_logo" />
</RelativeLayout>