首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用相对布局将按钮放在顶部和中间

使用相对布局将按钮放在顶部和中间
EN

Stack Overflow用户
提问于 2013-04-20 05:53:53
回答 1查看 75关注 0票数 0

我想有一个类似的布局

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

代码语言:javascript
复制
<?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>

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-20 05:55:52

似乎你所有的按钮图像都有相同的高度,所以为什么不直接使用TableLayout呢?保留左上角和右上角的单元格为空,在其他单元格中放置按钮。

代码(省略变量):

代码语言:javascript
复制
<TableLayout>
    <TableRow>
        <View />
        <Button>...</Button>
        <View />
    </TableRow>
    <TableRow>
        <Button>...</Button>
        <Button>...</Button>
        <Button>...</Button>
    </TableRow>
</TableLayout>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16114063

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档