0

Yo - Im trying to place a web view and a map view into the same activity but I'm having a bit of trouble. I'm trying to allow the web view to inhabit half of the screen and the other half will be occupied by the map view. Here is my code:

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

  <TableLayout
android:id = "@+id/embedded_map_Tble"
android:layout_width = "fill_parent"
android:layout_height = "fill_parent"
  >

  <TableRow
android:layout_weight = "1"
  >
<WebView
    android:id = "@+id/embedded_map_WebView"
    android:layout_width = "fill_parent"
    android:layout_height = "fill_parent"
    android:layout_weight = "1"
/>
  </TableRow>

  <TableRow>
   <com.google.android.maps.MapView 
        android:id="@+id/mapView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight = "1"
        android:layout_below = "@id/embedded_map_WebView"
        android:enabled="true"
        android:clickable="true"
        android:apiKey="MY_API_KEY"
        />
</TableRow>

</TableLayout>    

</RelativeLayout>
Katana24
  • 8,706
  • 19
  • 76
  • 118

1 Answers1

1

You should make both the views a part of a linerlayout , Set their height to 0dp , weight to 1 and set the orientation of the linear layout to vertical.

For more help refer this : Linear Layout and weight in Android

Community
  • 1
  • 1
Ravi Vyas
  • 12,212
  • 6
  • 31
  • 47
  • Thanks mate it worked well! But only one thing - when i drag my finger across the map ( top to bottom ) it moves the entire map view, or so it appears, down the screen. Is there any way to fix this? – Katana24 Mar 12 '12 at 15:46
  • As in when you move your finger from top to bottom accross the screen and continue over the webview your mapview still moves?? – Ravi Vyas Mar 12 '12 at 15:56
  • What i mean is that when i place my finger on the map view and drag down it seems to move the entire map and blank white spots appear. I think this is because the zoom level was set to the minimum and the white space was just that. Thanks for the help mate – Katana24 Mar 12 '12 at 16:09