在相对布局中使用权重来并排放置文本视图

Use weights in relative layout to have text views side by side

附件是我想要在 android 布局中使用的那种布局。我有两个彼此相邻的文本视图,每个文本视图水平覆盖了一半的地方。然后我在下面的 space 中有其他文本视图。

我打算使用相对布局,但后来我无法将它们并排放置并占用相同数量的 space。有人可以帮我实现这个目标吗?

试试这个方法

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center"
        android:text="hello " />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center"
        android:text="hello" />

</LinearLayout>

<TextView
    android:layout_marginTop="10dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="hello " />

<TextView
    android:layout_marginTop="10dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="hello" />

</LinearLayout>

试试下面的逻辑。

LinearLayout
    - Vertical Orientation
    - LinearLayout
        -HorizontalOrientation
        -weightSum=2
            -TextView1 with weight=1
            -TextView2 with weight = 1
    -TextView 3
    -TextView 4