Chance
Chance

Reputation: 988

Android, Eclipse: Item in .xml Layout Not Displaying in Graphical Layout

I am trying to add a spinner to my layout via Eclipse. I have added an item in the .xml, but the item is not displaying in the graphical layout. All I get are green arrows.

Here is what I'm seeing: Graphical Layout

Here is the .xml:

<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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.gui_test.MainActivity$PlaceholderFragment" >

    <ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="400dp"
        android:layout_centerHorizontal="true" >
    </ListView>

    <Button
        android:id="@+id/submitButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignRight="@+id/listView1"
        android:layout_below="@+id/listView1"
        android:layout_marginTop="17dp"
        android:text="Submit" />

    <Button
        android:id="@+id/refreshButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/submitButton"
        android:layout_alignBottom="@+id/submitButton"
        android:layout_alignLeft="@+id/listView1"
        android:text="Refresh" />

    <Spinner
        android:id="@+id/spinner1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/submitButton"
        android:layout_alignRight="@+id/refreshButton"
        android:layout_below="@+id/listView1"
        android:layout_marginRight="5dp" 
        android:layout_marginLeft="5dp"/>

</RelativeLayout>

I want the spinner to sit in between the "Refresh" and "Submit" buttons. How do I do this?

Upvotes: 0

Views: 203

Answers (1)

Sherif El Nady
Sherif El Nady

Reputation: 527

Try removing alignLeft and alignRight and add android:layout_centerHorizontal="true" then you can also add android:layout_alignTop="@+id/refreshButton" to align the spinner with the buttons from the top

Upvotes: 1

Related Questions