我有一个这样的布局,我想在视图上方显示一个标签,然后在下面重复它。
这是我的代码...
<RelativeLayout
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:orientation="vertical" >
    <TextView
        android:id="@+id/speedLbl"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20dp"
        android:text="@string/speed"
        android:textAppearance="?android:attr/textAppearanceLarge" />
    <View
        android:id="@+id/speedGraph"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="4dp"
        android:layout_below="@+id/speedLbl"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:background="@color/blueColour" />
    <TextView
        android:id="@+id/distanceLbl"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20dp"
        android:layout_below="@+id/speedGraph"
        android:text="@string/distance"
        android:textAppearance="?android:attr/textAppearanceLarge" />
    <View
        android:id="@+id/distanceGraph"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/distanceLbl"
        android:layout_marginBottom="4dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:background="@color/blueColour" />
</RelativeLayout>
问题是我不想为两个视图设置高度,因为我希望它们根据屏幕尺寸动态变化。
我尝试使用layout_weight,但它不喜欢它嵌套在另一个内部的事实。
谁能看到这个问题的另一种解决方案?