0
我想在一个RelativeLayout里面有两个相同高度的视图在另一个下面。 我不能使用LinearLayout的重量,所以我必须找出另一种方法来做到这一点。android里面的孩子在relativelayout相同的高度
从我谷歌搜索和阅读所以我发现作为一种解决方案,使用锚视图centerHorizontal在父视图中,并将2个孩子放在一个上面,一个在锚View下面,但它似乎不工作。
到目前为止我的代码是:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:gravity="top" >
<View android:id="@+id/anchor"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:background="#000"/>
<RelativeLayout
android:id="@+id/toplayout"
android:background="#990000"
android:layout_above="@+id/anchor"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/bottomlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/anchor">
<RatingBar
android:id="@+id/ratingBar1"
android:layout_width="218dp"
android:layout_height="wrap_content" />
</RelativeLayout>
</RelativeLayout>
有没有搞错我的代码或我试图解决问题的方法是从一开始就错了吗?