【发布时间】:2012-04-17 04:24:20
【问题描述】:
我有一个我认为很简单的布局。这包含一个滚动视图,其中包含一个水平滚动视图,因此我可以双向滚动。我已经简化了这个例子,所以它只有一个包含一个TextView 和另一个RelativeLayout 的RelativeLayout。这是 XML:
<HorizontalScrollView
android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fadeScrollbars="false"
android:scrollbarAlwaysDrawHorizontalTrack="true"
android:fillViewport="true">
<RelativeLayout
android:id="@+id/mainLayout"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<TextView
android:id="@+id/myText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEXT LABEL" />
<RelativeLayout
android:id="@+id/relativeLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/myText">
<Button android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/button1"
android:layout_above="@+id/button1"
android:text="2"/>
<Button android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"/>
<Button android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button1"
android:text="3"/>
</RelativeLayout>
</RelativeLayout>
</HorizontalScrollView>
</ScrollView>
我可以看到按钮 1 和 3,但我没有看到按钮 2。不幸的是,我需要这样做,因为页面是动态构建的(这个 xml 是我正在做的简化版本)而且我只知道我需要留下什么。我曾经让它工作,但不得不重新安排其他一些代码,它坏了。我错过了什么?
这是快照的链接:snapshot
【问题讨论】:
-
你能发一个链接到它现在的样子吗?
-
按钮2应该放在哪里?
-
button2 应该与 button1 的左上角对齐。我知道我可以将 button1 与 button2 的右下角对齐,但我需要以这种方式构建它。
标签: android android-relativelayout