我希望在行的右侧有按钮B1和B2,按钮A1和A2位于该行剩余空间的中心。避免布局冗余
这是可能的,而不包裹按钮的两次?
下面是具体问题的具体细节。
Eclipse中表示,“这的LinearLayout布局或RelativeLayout的父母可能是无用的”批评了两家母公司布局,@id/buttonAx
。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/myRightMostLL"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" >
<Button
android:id="@+id/buttonB1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="B1" />
<Button
android:id="@+id/buttonB2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="B2" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/myRightMostLL">
<LinearLayout
android:id="@+id/remainderLL"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
<Button
android:id="@+id/buttonA1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A1" />
<Button
android:id="@+id/buttonA2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A2" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
然而我需要这种无用的能够将按钮A置于按钮B布置后剩余的空间中。只有一个按钮A的父包装布局可以获得相同的效果吗?
在这样的布局中,我也经常质疑@ id/myRightMostLL是否真的有必要在文件中出现第一个。
除了为按钮A设置左右边距之外,我无法真正想到另一种解决方案,但我不认为这将是一种多用途的方法。老实说,如果它正在产生所需的结果,我只是压制这个警告,因为它只是不明白你需要什么。 – user2483079
附加按钮是否与ButtonA,ButtonB或每个按钮分组?他们将如何定位?最好告诉我们您的实际需求,而不是模糊的警告,即只有两个按钮的解决方案不适合您。 –
@TedHopp Done .. – Calaf