views:

256

answers:

2

I have a RelativeLayout, and this Layout has two childs, one is a MapView and the other a RelativeLayout that contains a button.

I want it to look like that http://pocketjourney.files.wordpress.com/2008/03/goal.gif but my transparent box (a relativelayout) is always displayed at the top of the map.

<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>   

(i've left out some things in the code)

+1  A: 

Try adding a alignParentBottom option to the transparent panel.

<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> 
Konstantin Burov
A: 

As Konstantin pointed out use layout_alignParentBottom to position the button at the bottom of your view. The problem now is that the mapview will also stretch itself out to the bottom of the parent. Therefore the mapview will ´grow´ under the button until the parent is filled.

Try the following. First position the button at the bottom of the parent view, then align above the button.

<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> 
Janusz