I have a spinner which is in the parent layout, which holds the Spinner, and nested Relative layouts. The problem I am having is that I cannot seem to get the Spinner to align to this parent layout, even when I specify to align in parent, it still aligns to a nested view.
To clarify: My Spinner is being aligned to the top left of “relativeone”, not “back_layout”.
Any ideas?
Relevant XML code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/back_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
android:gravity="center"
>
<Spinner
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:background="#FFFFFF"
android:entries="@array/spinner"
android:layout_alignLeft="@+id/relativeone" />
<RelativeLayout
android:id="@+id/relativeone"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_gravity="center"
android:gravity="center">
<RelativeLayout
android:id="@+id/relativetwo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:gravity="center" >
<ImageView
android:id="@+id/imageview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_gravity="center"
android:scaleType="fitXY" />
<Button
android:id="@+id/buttonone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Take Photo" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
You need to make some minor changes to your properties to make it work.
Drop the center align from
back_layout, drop the align left from the spinner, and add center in parent torelativeone.Tha above layout will give you this: