2013-02-12 45 views
5

我有一個安卓地圖api v2的地圖視圖,使用此滑動菜單的活動https://github.com/iPaulPro/SlidingMenu。除了在地圖頁面上,滑動菜單的效果很好。有一個覆蓋滑動菜單的黑色視圖,即地圖的確切大小。這是一個地圖高度設置爲100dp的例子,以概述我的意思。安卓MapView與滑動菜單遮擋菜單

View Issue

如果我碰這種觀點它會自行消失。我將如何擺脫它或使其透明?我已經嘗試了requestTransparentRegion()技巧。那裏沒有骰子。

+1

這是什麼iOS搜索欄???這只是看起來錯了... – 2013-02-12 20:38:50

+0

只是遵循的comps。 – smokingoyster 2013-02-12 21:42:48

+0

看看這些:http://www.grokkingandroid.com/android-tutorial-adding-suggestions-to-search/ – 2013-02-13 06:34:52

回答

13

發現這個堆棧溢出後ViewPager with Google Maps API v2: mysterious black view和使用這個類代替法線地圖片段。

package com.myapp.gms.maps; 

import android.os.Bundle; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 
import android.view.ViewGroup.LayoutParams; 
import android.widget.FrameLayout; 
import com.google.android.gms.maps.SupportMapFragment; 

/** 
* @author btate 
*/ 
public class TransparentSupportMapFragment extends SupportMapFragment { 

    public TransparentSupportMapFragment() {} 

    @Override 
    public View onCreateView(LayoutInflater inflater, 
           ViewGroup view, 
           Bundle savedInstance) { 

     View layout = super.onCreateView(inflater, view, savedInstance); 
     FrameLayout frameLayout = new FrameLayout(getActivity()); 
     frameLayout.setBackgroundColor(
      getResources().getColor(android.R.color.transparent)); 
     ((ViewGroup) layout).addView(frameLayout, 
      new ViewGroup.LayoutParams(
       LayoutParams.MATCH_PARENT, 
       LayoutParams.MATCH_PARENT 
      ) 
     ); 
     return layout; 
    } 

} 
+0

哥們,你救了我一天 – 2013-03-26 17:02:47

+0

偉大的答案thanx – Ravi 2013-06-04 10:07:01

0

這個問題還有一個解決方案。我在另一個片段中顯示MapFragment。 MapFragment被動態添加到FrameLayout中。

解決方案是在滑動菜單的打開和關閉事件上使用frameLayout.setVisibility(View.Visible)frameLayout.setVisibility(View.Gone)。它不需要添加額外的視圖。黑色區域完全消失了。

getSlidingMenu().setOnOpenListener(
    new OnOpenListener() { 
     @Override 
     public void onOpen() { 
      frameLayout.setVisibility(View.GONE); 
     } 
    } 
); 

getSlidingMenu().setOnClosedListener(
    new OnClosedListener() { 

     @Override 
     public void onClosed() { 
      frameLayout.setVisibility(View.VISIBLE); 
     } 
    } 
); 
0

TransparentSupportMapFragment解決的問題爲Android 2.3.7 謝謝!