2010-08-16 9 views
2

저는 RelativeLayout이며,이 레이아웃에는 두 개의 자식이 있습니다. 하나는 MapView이고 다른 하나는 버튼이 들어있는 RelativeLayout입니다.RelativeLayout의 맨 아래에 RelativeLayout을 배치하는 방법은 무엇입니까?

나는 항상지도의 상단에 표시되는

하지만 내 투명 상자 (A RelativeLayout)처럼 보이게합니다.

<RelativeLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"> 

    <com.google.android.maps.MapView 
    android:id="@+id/mapView"/> 

    <test.project.TransparentPanel 
     android:layout_width="fill_parent" 
     android:layout_width="fill_parent"> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Click Me!"/> 

    </test.project.TransparentPanel> 

</RelativeLayout> 

투명 패널로 alignParentBottom 옵션을 추가

답변

6

시도 (난 코드에서 몇 가지를 남겨 두었다).

콘스탄틴이보기의 맨 아래에있는 버튼의 위치를 ​​사용 layout_alignParentBottom을 지적
<RelativeLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"> 

    <com.google.android.maps.MapView 
    android:id="@+id/mapView"/> 

    <test.project.TransparentPanel 
    android:layout_width="fill_parent" 
    android:layout_width="fill_parent" 
    android:layout_alignParentBottom="true"> 

     <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Click Me!"/>   

    </test.project.TransparentPanel> 

</RelativeLayout> 
2

. 이제 문제는지도 뷰가 부모의 맨 아래로 확장된다는 것입니다. 따라서 부모가 채워질 때까지지도보기가 버튼 아래로 확대됩니다.

다음을 시도해보십시오. 먼저 부모보기의 맨 아래에 단추를 놓은 다음 단추 위에 정렬하십시오.

<RelativeLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"> 

    <test.project.TransparentPanel 
    android:id="@+id/button_area" 
    android:layout_width="fill_parent" 
    android:layout_width="fill_parent" 
    android:layout_alignParentBottom="true"> 

     <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Click Me!"/>   

    </test.project.TransparentPanel> 

    <com.google.android.maps.MapView 
    android:id="@+id/mapView" 
    layout_above="@id/button_area"/> 

</RelativeLayout> 
관련 문제