【发布时间】:2014-02-27 22:37:49
【问题描述】:
我是新的机器人。在为 Android 设计布局时,我有一点点堆栈。在我的场景中,我有两个带有线性布局的按钮。这是我的 xml。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="@color/isp_home_color"
>
<Button
android:layout_width="0dp"
android:layout_height="70dp"
android:layout_weight="1"
android:text="@string/sync_text"
android:background="@color/sync_text_color"
android:id="@+id/btn_syncpin"
android:layout_gravity="left"
android:textStyle="bold"
/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="70dp"
android:text="@string/topup_text"
android:background="@color/topup_text_color"
android:id="@+id/btn_topup"
android:layout_gravity="right"
android:textStyle="bold"/>
<!--Table Layout will come here -->
</LinearLayout>
这里的图片。
当我在线性布局中添加新的 TableLayout 时。我懂了。
这是我的 xml 用于表格布局。
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</TableLayout>
其实,我不想这样。我想要两个按钮,如第一张图片所示。然后,下一个表格布局将出现在这两个按钮下。请帮助我如何进行这种布局。请指点我如何做到这一点。感谢先进。
【问题讨论】:
-
把它全部打包成一个相对布局?因为 LinearLayout 将事物一个接一个地放置,这就是这种行为的原因。罪魁祸首是
android:orientation="horizontal",所以在添加两个按钮后,表格布局会在水平方向的这两个按钮之后。
标签: android android-layout layout