2011-12-30 17 views
5

Este es mi código fuente xml de Android para un mapa: diseño de la barra inferior. Estoy mostrando un mapa enorme en la pantalla y necesito un diseño de 30dp de alto en la parte inferior de la pantalla para mostrar algunas pestañas como imágenes. ¿Cómo presiono el diseño lineal horizontal hasta el final de la página?Disposición de la barra inferior en Android

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height=" what here ? " 
    android:layout_width="fill_parent" 
    android:orientation="vertical"> 
    <com.google.android.maps.MapView 
     android:id="@+id/map_view" 
     Map goes here. Almost full screen. Exactly full - 30dp; 

     /> 
    <LinearLayout> 
     I want 3 images here. Bottom of the screen. 
    </LinearLayout> 
</RelativeLayout> 
+0

ver esto: http://stackoverflow.com/questions/36019986/which-view-should-be-used-for-new-material-design-bottom- navegación/42119958 # 42119958 – Fartab

Respuesta

9

Uso android:layout_alignParentBottom="true" para ajustar el LinearLayout en la parte inferior de la matriz para LinearLayout y android:layout_above para MapView para establecer el MapView por encima de la LinearLayout.

Su código será:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent" 
    android:orientation="vertical"> 

    <LinearLayout android:layout_height="30dip" 
     android:layout_width="fill_parent" 
     android:layout_alignParentBottom="true" 
     android:id="@+id/linearLayout1" 
    > 
     <!-- ... --> 
    </LinearLayout> 

    <com.google.android.maps.MapView 
     android:id="@+id/map_view" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:layout_above="@+id/linearLayout1" 
    /> 
</RelativeLayout> 
-2

Pruebe la distribución siguiente. Usar android:layout_alignParentBottom="true" no será suficiente ya que MapView con android:layout_height="fill_parent" llenará toda la pantalla y ocultará LinearLayout. También debe agregar android:layout_above="@id/menu" para que no lo oculte.

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

    <com.google.android.maps.MapView 
     android:id="@+id/map" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_above="@id/menu" 
     android:apiKey="@string/google_maps_api_key" 
     android:clickable="true" /> 

    <LinearLayout 
     android:id="@+id/menu" 
     android:layout_width="fill_parent" 
     android:layout_height="30dp" 
     android:layout_alignParentBottom="true" > 
    </LinearLayout> 

</RelativeLayout> 
+0

el diseño se superpondrá al mapa –

+0

¿Por qué? Es lo mismo que el tuyo – Flo

1
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <com.google.android.maps.MapView 
     android:id="@+id/map_view" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_above="@+id/rel_bottom" /> 

    <RelativeLayout 
     android:id="@+id/rel_bottom" 
     android:layout_width="fill_parent" 
     android:layout_alignParentBottom="true" 
     android:layout_height="30dp" > 

     <ImageView 
      android:id="@+id/img1" 
      android:layout_width="40dp" 
      android:layout_height="fill_parent" /> 

     <ImageView 
      android:id="@+id/img2" 
      android:layout_width="40dp" 
      android:layout_height="fill_parent" 
      android:layout_toRightOf="@+id/img1" /> 

     <ImageView 
      android:id="@+id/img3" 
      android:layout_width="40dp" 
      android:layout_height="fill_parent" 
      android:layout_toRightOf="@+id/img2" /> 
    </RelativeLayout> 

</RelativeLayout> 
+0

por error edité tu respuesta, lo siento –

0

utilizar las propiedades de la RelativeLayout, como android:layout_alignParentBottom y android:layout_above.

me gustaría hacer algo como esto:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_height="fill_parent" 
android:layout_width="fill_parent"> 

    <LinearLayout 
     android:id="@+id/footer" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:width="fill_parent" 
     android:height="30dp"> 

      add your images here 

    </LinearLayout> 

    <com.google.android.maps.MapView 
     android:id="@+id/map_view" 
     android:height="fill_parent" 
     android:width="fill_parent" 
     android:layout_alignParentTop="true" 
     android:layout_above="@id/footer"/> 

</RelativeLayout> 
Cuestiones relacionadas