2013-04-22 3 views
1

Я использую карту Google в моем андроиде app.I создала MapView в XML-файл, что он работает нормально, но когда я поставил MapView в Scrollview это показывает OutOfMemoryError и аварии ,Android карты, показывающая из памяти ошибок

Вот мой XML-код:

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

    <RelativeLayout 
     android:id="@+id/main_layout" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" > 

     <RelativeLayout 
      android:id="@+id/header_layout" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:background="@drawable/share_header" > 

      <Button 
       android:id="@+id/back_button" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_centerVertical="true" 
       android:background="@drawable/back" /> 

      <TextView 
       android:id="@+id/header_txt" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerInParent="true" 
       android:textStyle="bold" /> 

      <Button 
       android:id="@+id/post_button" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_centerVertical="true" 
       android:background="@drawable/post" /> 
     </RelativeLayout> 

     <RelativeLayout 
      android:id="@+id/share_leave_note_layout" 
      android:layout_width="wrap_content" 
      android:layout_height="150dip" 
      android:layout_below="@+id/header_layout" 
      android:layout_marginLeft="10dip" 
      android:layout_marginRight="10dip" 
      android:layout_marginTop="5dip" > 

      <ImageView 
       android:id="@+id/sharer_img" 
       android:layout_width="40dip" 
       android:layout_height="40dip" 
       android:background="@drawable/img_box" /> 

      <RelativeLayout 
       android:id="@+id/leave_note_layout" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_toRightOf="@+id/sharer_img" 
       android:background="@drawable/comment_left_arrow_extra_big" > 

       <EditText 
        android:id="@+id/leave_note_edt" 
        android:layout_width="170dip" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="10dip" 
        android:layout_marginRight="15dip" 
        android:layout_marginTop="10dip" 
        android:background="@null" 
        android:hint="@string/laeve_a_note_text" /> 

       <ImageView 
        android:id="@+id/captured_img" 
        android:layout_width="40dip" 
        android:layout_height="40dip" 
        android:layout_margin="10dip" 
        android:layout_toRightOf="@+id/leave_note_edt" 
        android:background="@drawable/img_box" /> 
      </RelativeLayout> 
     </RelativeLayout> 

     <RelativeLayout 
      android:id="@+id/iamat_and_with_layout" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/share_leave_note_layout" 
      android:layout_marginLeft="10dip" 
      android:layout_marginRight="10dip" 
      android:layout_marginTop="5dip" 
      android:gravity="center_vertical" > 

      <Button 
       android:id="@+id/web_btn" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/web" /> 

      <Button 
       android:id="@+id/iam_at_btn" 
       android:layout_width="90dip" 
       android:layout_height="wrap_content" 
       android:layout_toRightOf="@+id/web_btn" 
       android:background="@drawable/i_m_at" /> 

      <Button 
       android:id="@+id/contact_logo_btn" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_toRightOf="@+id/iam_at_btn" 
       android:background="@drawable/contact_group" /> 

      <Button 
       android:id="@+id/iam_with_btn" 
       android:layout_width="90dip" 
       android:layout_height="wrap_content" 
       android:layout_toRightOf="@+id/contact_logo_btn" 
       android:background="@drawable/i_m_with" /> 
     </RelativeLayout> 

     <FrameLayout 
      android:id="@+id/map_contact_layout" 
      android:layout_width="150dip" 
      android:layout_height="150dip" 
      android:layout_below="@+id/iamat_and_with_layout" 
      android:layout_marginLeft="10dip" 
      android:layout_marginTop="5dip" 
      android:background="@drawable/rectangle_img" 
      android:gravity="center_vertical" > 

      <com.google.android.maps.MapView 
       android:id="@+id/mapView" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:apiKey="0_oThqu6ib8WYroWAckbRjYAkaoeMUX-52diovQ" 
       android:clickable="true" 
       android:enabled="true" /> 
     </FrameLayout> 

     <RelativeLayout 
      android:id="@+id/contact_layout" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/iamat_and_with_layout" 
      android:layout_toRightOf="@+id/map_contact_layout" 
      android:gravity="center_vertical" > 

      <ImageView 
       android:id="@+id/contact_img1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dip" 
       android:background="@drawable/square" /> 

      <ImageView 
       android:id="@+id/contact_img2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dip" 
       android:layout_toRightOf="@+id/contact_img1" 
       android:background="@drawable/square" /> 

      <ImageView 
       android:id="@+id/contact_img3" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/contact_img1" 
       android:layout_margin="5dip" 
       android:background="@drawable/square" /> 

      <ImageView 
       android:id="@+id/contact_img4" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/contact_img2" 
       android:layout_margin="5dip" 
       android:layout_toRightOf="@+id/contact_img3" 
       android:background="@drawable/square" /> 
     </RelativeLayout> 

     <RelativeLayout 
      android:id="@+id/fb_twitter_layout" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentRight="true" 
      android:layout_below="@+id/contact_layout" 
      android:layout_marginRight="5dip" 
      android:background="@null" > 

      <ImageView 
       android:id="@+id/fb_fade_icon" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dip" 
       android:background="@drawable/fb_fade" /> 

      <ImageView 
       android:id="@+id/twitter_fade_icon" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dip" 
       android:layout_toRightOf="@+id/fb_fade_icon" 
       android:background="@drawable/twitter_fade" /> 
     </RelativeLayout> 
    </RelativeLayout> 

</ScrollView> 
+0

MapView устарел Использовать Android MapV2 – Abhi

ответ

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

    <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent"> 

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

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

       <view android:layout_width="100dip" android:layout_height="90dip" class="com.google.android.maps.MapView" 
        android:apiKey="0_oThqu6ib8WYroWAckbRjYAkaoeMUX-52diovQ" android:clickable="true" /> 

      </FrameLayout> 

     </RelativeLayout> 
    </ScrollView> 
</RelativeLayout> 

PS: Последние версии карт Google Maps Android API v2. Попытайтесь использовать его. Вот хороший tutorial для этого.

+0

Спасибо, Бишан работает. –

Смежные вопросы