简体   繁体   中英

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: 图形布局

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?

尝试删除alignLeft和alignRight并添加android:layout_centerHorizo​​ntal =“ true”,然后您还可以添加android:layout_alignTop =“ @ + id / refreshButton”将微调器与顶部的按钮对齐

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM