2013-02-20 73 views
6

如何使黑色背景在谷歌地圖v2滾動時透明?android谷歌地圖v2片段黑色問題

<RelativeLayout 
        android:id="@+id/relativeLayout1" 
        android:layout_width="match_parent" 
        android:layout_height="134dp" 
        android:layout_alignParentTop="true" 
        android:layout_gravity="center" > 

        <fragment 
         xmlns:android="http://schemas.android.com/apk/res/android" 
         android:id="@+id/map" 
         android:layout_width="fill_parent" 
         android:layout_height="434dp" 
         android:layout_marginBottom="-150dp" 
         android:layout_marginLeft="3dp" 
         android:layout_marginRight="3dp" 
         android:layout_marginTop="-150dp"      
         class="com.google.android.gms.maps.SupportMapFragment" 
         android:cacheColorHint="@color/transparent" 
         android:clickable="true" /> 

        <FrameLayout 
         android:id="@+id/fram_lay" 
         android:layout_width="match_parent" 
         android:layout_height="172dp" > 

         <android.support.v4.view.ViewPager 
          android:id="@+id/fragment_container" 
          android:layout_width="fill_parent" 
          android:layout_height="134dp" > 
         </android.support.v4.view.ViewPager> 

         <FrameLayout 
          android:id="@+id/fram_lay2" 
          android:layout_width="match_parent" 
          android:layout_height="334dp" 
          android:layout_marginTop="-100dp"        
          android:background="@android:color/transparent" 
          android:cacheColorHint="#00000000" /> 
        </FrameLayout> 
       </RelativeLayout> 

我給了地圖上的透明框架,但它仍然閃爍。 請別人給我 謝謝

回答

0

透明框上的MapView只能解決黑洞問題的解決方案,閃爍依然每次都會發生的地圖重新加載它的資源,即當OnCreateView()被調用。

嘗試發佈解決方案here,在主Activity中添加一個MapView,然後在初始化後隱藏它。

0

背後的原因是Map使用SurfaceView,當App創建這個視圖時,它會在您的Activity的後面創建一個Window,並在您的Activity的窗口中打出一個洞,這意味着SurfaceView的原始位置下無法看到。

對我來說,這就像魅力的工作,你可以使用這個庫

https://github.com/NyxDigital/NiceSupportMapFragment/

這個工作正常,我。