Android 相对文本视图上方居中的三个按钮

Android 相对文本视图上方居中的三个按钮,android,button,alignment,textview,Android,Button,Alignment,Textview,所以在我的布局中,我在同一条线上有三个按钮,一个左、中、右对齐。我在按钮下面也有文本视图作为标签,但它们也分别左对齐、居中对齐和右对齐。我想让它们在按钮下方居中,彼此在同一条线上,但如果不明确设置坐标,我就不知道该怎么做,这会在一些手机上中断。我试着设置不同的权重和布局选项,但它就是不工作,我想。有没有一种方法可以在相对论中做到这一点?也许这是不可能的。最后,我在同一行上有三个以上的文本视图,在底部有一个按钮。我想如下所示对齐: 提前感谢。您不能使用RelativeLayout将一个元素置于另

所以在我的布局中,我在同一条线上有三个按钮,一个左、中、右对齐。我在按钮下面也有文本视图作为标签,但它们也分别左对齐、居中对齐和右对齐。我想让它们在按钮下方居中,彼此在同一条线上,但如果不明确设置坐标,我就不知道该怎么做,这会在一些手机上中断。我试着设置不同的权重和布局选项,但它就是不工作,我想。有没有一种方法可以在相对论中做到这一点?也许这是不可能的。最后,我在同一行上有三个以上的文本视图,在底部有一个按钮。我想如下所示对齐:


提前感谢。

您不能使用RelativeLayout将一个元素置于另一个元素的中心。您可以尝试使用三个相对位置(每列一个)的水平线性布局。您可以将整个内容包含在垂直线性布局中,以获得底部按钮


TableLayout或GridLayout也是可能的。

正如人们所建议的,在
RelativeLayout中,无法将
视图
集中在另一个
视图
的下方。如果您可以确认
TextView
宽度不必大于
按钮的宽度,您可以使用此黑客。解决方案是:使
TextView
的左右边缘与上面的
按钮对齐。然后将
TextView
的重心设置为
center
,以便
TextView
中的文本居中

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

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="130dp"
        android:text="Button1" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/button1"
        android:layout_alignBottom="@+id/button1"
        android:layout_centerHorizontal="true"
        android:text="Button2" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/button2"
        android:layout_alignBottom="@+id/button2"
        android:layout_alignParentRight="true"
        android:text="Button3" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@id/button1"
        android:layout_alignRight="@id/button1"
        android:layout_below="@+id/button1"
        android:layout_marginTop="50dp"
        android:gravity="center"
        android:text="Txt1" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@id/button2"
        android:layout_alignRight="@id/button2"
        android:layout_below="@+id/button2"
        android:layout_marginTop="50dp"
        android:gravity="center"
        android:text="Txt2" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@id/button3"
        android:layout_alignRight="@id/button3"
        android:layout_below="@+id/button3"
        android:layout_marginTop="50dp"
        android:gravity="center"
        android:text="Txt3" />

</RelativeLayout>


我正在努力理解你的意思,你能画出你想要的东西吗?:)我不知道你到底有什么问题。我知道你想要什么,但是你能拍下你的UI设计师的截图让我们看看问题出在哪里吗?