我有一个相对布局,我有两个按钮,分别带有文本"hello"和"world".我希望这两个按钮彼此相邻,同样占据整个水平空间.
我尝试了以下但没有得到预期的输出
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/world" android:id="@+id/world"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/hello"
android:layout_alignTop="@+id/hello"
/>
<Button
android:id="@+id/hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我尝试将两个孩子的android:layout_width更改为fill_parent,但这也没有用.
我有一个使用LinearLayout和layout_weight设置为0.5的两个孩子的工作解决方案,但我想了解是否有相关布局本身的方法.
谢谢,