相关疑难解决方法(0)

android:相对布局两个按钮占用所有可用的水平空间

我有一个相对布局,我有两个按钮,分别带有文本"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的两个孩子的工作解决方案,但我想了解是否有相关布局本身的方法.

谢谢,

android android-layout

13
推荐指数
3
解决办法
1万
查看次数

标签 统计

android ×1

android-layout ×1