简体   繁体   English

Android,Eclipse:.xml布局中的项目不在图形布局中显示

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

I am trying to add a spinner to my layout via Eclipse. 我试图通过Eclipse将微调器添加到布局中。 I have added an item in the .xml, but the item is not displaying in the graphical layout. 我在.xml中添加了一个项目,但是该项目未显示在图形布局中。 All I get are green arrows. 我得到的只是绿色箭头。

Here is what I'm seeing: 这是我所看到的: 图形布局

Here is the .xml: 这是.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”将微调器与顶部的按钮对齐

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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