【发布时间】:2010-10-02 13:47:16
【问题描述】:
这更多是出于好奇,因为我已经解决了我最初的问题。我想要一个按钮位于屏幕的水平中心,左侧有一个文本框,使用相对布局。如果我有以下布局,我很想知道为什么:
<Button android:id="@+id/pickTime"
android:layout_width="wrap_content"
android:layout_below="@id/to_button"
android:layout_centerHorizontal="true"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/timetext"
android:layout_width="wrap_content"
android:layout_below="@id/to_button"
android:layout_toLeftOf="@id/pickTime"
android:layout_alignTop="@id/pickTime"
android:layout_height="wrap_content"/>
TextView 不显示,但如果我替换:
android:layout_toLeftOf="@/id/pickTime"
到
android:layout_alignParentLeft="true"
它确实显示(尽管左对齐到左边距而不是右对齐到我最初期望的按钮)。这是所有相对布局的问题(即总是必须按设定的顺序定义小部件),还是只是与需要从左侧读取的文本有关?
【问题讨论】: