0

我的应用中有一个布局,它有四个图像按钮。我希望最后两个图像按钮,重新加载和停止按钮位于屏幕右侧,两个按钮之间有空白空间。我将如何实现这一目标?我听说过 Space,但它是在 API 级别 14 中添加的,我想保持我的 minSdkVersion 为 8。布局中的图像按钮

4

3 回答 3

0

创建一个线性布局并将这两个按钮添加到具有水平方向的线性布局中..并将线性布局定位到父布局的右侧,这可能是 alignParentRight = "true" 的相对布局 - 希望它有所帮助.. 如果你不得到它告诉我提供代码??

编辑 1:代码

 <RelativeLayout 
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

  </LinearLayout>

</RelativeLayout>

将此相对于您已有的布局发布并删除要向右对齐的两个按钮将其替换为此处的两个按钮..就是这样..让我知道最新情况

于 2014-10-16T01:44:11.327 回答
0

您可能可以使用 aRelativeLayout通过利用layoutxml 中的属性来实现此目的。您可以将X按钮/图像对齐到父级的左下角,然后将刷新按钮对齐到按钮的右侧X

链接到有用的信息 - http://developer.android.com/guide/topics/ui/layout/relative.html

于 2014-10-16T01:45:44.053 回答
0

将所有 4 个按钮放在相对布局中。每 2 个按钮应该有一个线性布局父级。第一个线性布局应该有alignParentLeft = true属性,而第二个线性布局(重新加载和停止的容器)应该有alignParentRight = true属性。

或者您可以简单地将它们放在相对布局上..然后手动对齐。使用 to rightOf,to LeftOf 属性。

希望这可以帮助!:)

于 2014-10-16T04:29:18.457 回答