[英]How to remove black cover on top of sliding menu?
在我的應用程序中,我有一個由jfeinstein10開發的滑動菜單。 它在我的應用程序中正常工作;)
我有一個片段,它是MapView的主機。 這個片段就像我從Fragment類擴展的其他片段一樣。 就在這個片段中,當我打開滑動菜單時,菜單內容頂部有黑色封面/圖層。 當我打開其他片段的菜單時,沒有黑色封面。 另外,我發現的東西是盒子的高度與片段的高度完全相同。
你以前見過這個問題嗎? 任何意見或建議將不勝感激。
=> 更新
根據Selei的建議,我將背景設置為透明。 但是,無論我指定的顏色(透明或其他顏色),它仍然可見和黑色:(這是我的代碼:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.gms.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
map:uiCompass="true"
android:background="#00000000"/>
解決方案是將map:zOrderOnTop="true"
到XML。
有關詳細信息,請參閱此鏈接 。
我在這里嘗試了所有的方法,但沒有一個很好用。 使用GoogleOptions將zOrder移動到頂部意味着基本縮放控件隱藏在地圖后面。
這個鏈接的最后一個建議: https : //github.com/jfeinstein10/SlidingMenu/issues/168#issuecomment-17065660 (ckakei)為我修復了它。
訣竅是為布局添加一個空的透明視圖:
<?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" >
<FrameLayout
android:id="@+id/view_map"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</FrameLayout>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent" />
我正在片段中誇大這個觀點。 我將view_map FrameLayout替換為SuppportMapFragment。
這是該課程的重要部分:
private GoogleMap googleMap;
private SupportMapFragment mapFragment;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.view_map_layout, container,
false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
FragmentManager fm = getChildFragmentManager();
if (mapFragment == null) {
mapFragment = SupportMapFragment.newInstance();
}
if (savedInstanceState == null) {
mapFragment.setRetainInstance(true);
} else {
googleMap = mapFragment.getMap();
}
fm.beginTransaction().replace(R.id.view_map, mapFragment).commit();
}
設置MapView背景透明 - android:background =“#00000000”
我只是制作了地圖復制視圖,當滑動菜單打開或關閉時復制地圖
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
private void showMapCopy(boolean show) {
View map = findViewById(R.id.map);
View mapCopy = findViewById(R.id.map_copy);
if (show) {
map.setDrawingCacheEnabled(true);
Bitmap bitmap = map.getDrawingCache();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
mapCopy.setBackgroundDrawable(new BitmapDrawable(getResources(), bitmap));
else
mapCopy.setBackground(new BitmapDrawable(getResources(), bitmap));
mapCopy.setVisibility(View.VISIBLE);
} else {
map.setDrawingCacheEnabled(false);
mapCopy.setVisibility(View.GONE);
}
}
滑動菜單打開監聽器
mMenu.setOnClosedListener(new OnClosedListener() {
@Override
public void onClosed() {
showMapCopy(false);
}
});
OnOptionItemSelected
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.abs__home:
case android.R.id.home:
showMapCopy(true);
mMenu.toggle();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.