0

我有一个相对布局的设计,它有一个中心元素。我想要该中心元素左侧的另一个元素,并且这两个元素的底部应该处于同一水平。我试过 alignBaseline 但没用。

请帮忙 ... !!!

4

2 回答 2

1

这对我有用。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ff0" >

    <Button
        android:id="@+id/first"
        android:layout_width="50dip"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_marginTop="5dip" />

    <Button
        android:id="@+id/second"
        android:layout_width="50dip"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/first"
        android:layout_alignBottom="@+id/first"
        android:layout_toRightOf="@+id/first" />

</RelativeLayout>
于 2013-10-22T16:52:29.080 回答
0

您必须使用 RelativeLayout 的属性,请在此处查看说明和一些示例。

但总而言之,您需要:

android:layout_toLeftOf="@+id/center_element"

android:layout_alignBottom="@+id/center_element"

于 2013-10-22T16:47:15.020 回答