0

我想要一个类似于

所需布局:

有点内疚,因为我最近刚问了一个关于布局的问题,但我不知道我需要这样做(我也不知道这很难),我研究了 View Layouts 并尝试过使用layout.toRightOf等。我有左/右箭头,我只需要添加向上和向下按钮

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:game_view="http://schemas.android.com/apk/res/pap.crowslanding"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >

<FrameLayout
    android:id="@+id/flayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_above="@+id/button1"
    android:orientation="vertical" >

    <pap.crowslanding.GameView
        android:id="@+id/game_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        game_view:ballDiam="@dimen/ballDiam"
        game_view:cellWidth="@dimen/cellWidth"
        game_view:pixelHeight="@dimen/pixelHeight"
        game_view:pixelWidth="@dimen/pixelWidth" />

    <pap.crowslanding.MazeBall
        android:id="@+id/mazeball"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:visibility="invisible"
        game_view:ballDiam="@dimen/ballDiam"
        game_view:cellWidth="@dimen/cellWidth" />
</FrameLayout>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/button1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/right" >
    </Button>

    <Button
        android:id="@+id/button2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/down" />
</LinearLayout>

</RelativeLayout>

所以本质上,只是对如何在同一布局中添加向上和向下按钮的一些见解,以避免布局绘制到我的活动上并重叠

4

1 回答 1

1

似乎您所有的按钮图像都具有相同的高度,那么为什么不使用 aTableLayout呢?保持左上角和右上角的单元格为空,并在其他单元格中放置您的按钮。

代码(省略变量):

<TableLayout>
    <TableRow>
        <View />
        <Button>...</Button>
        <View />
    </TableRow>
    <TableRow>
        <Button>...</Button>
        <Button>...</Button>
        <Button>...</Button>
    </TableRow>
</TableLayout>
于 2013-04-19T21:55:52.007 回答