행의 오른쪽에 Buttons B1과 B2가 있고 그 행의 나머지 공간의 가운데에 Button A1과 A2가 있습니다.레이아웃 중복 피하기
이 포장 버튼 두 번없이 수 있습니까?
여기에 구체적인 질문이 있습니다.
Eclipse는 두 개의 상위 레이아웃을 @id/buttonAx
으로 비평합니다. "이 LinearLayout 레이아웃 또는 RelativeLayout 부모는 아마도 쓸모가 없습니다."라고 비평합니다.
<?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>
아직 버튼 B를 배치 한 후에 남아있는 공간에 버튼 A를 가운데 놓을 수 있어야합니다. 버튼 A에 대한 하나의 상위 래퍼 레이아웃으로 동일한 효과를 얻을 수 있습니까?
이와 같은 레이아웃에서도 @ id/myRightMostLL이 첫 번째로 인 파일에 표시되어야하는지 여부에 대해 자주 질문합니다.
버튼 A의 왼쪽 여백과 오른쪽 여백을 설정하는 것 외에 다른 해결책을 생각할 수는 없지만 그 방법은 다양 할 것이라고 생각하지 않습니다. 솔직히 원하는 결과를 얻는다면 나는 단지 당신이 필요로하는 것을 이해하지 못하기 때문에 그 경고를 그냥 억제 할 것입니다. – user2483079
추가 버튼이 ButtonA, ButtonB 또는 일부 그룹으로 그룹화됩니까? 어떻게 배치 될 것입니까? 두 개의 버튼으로 만 구성된 솔루션이 효과가 없을 것이라는 모호한 경고 대신 실제 요구 사항을 알려주는 것이 좋습니다. –
@TedHopp Done .. – Calaf