Android 如何卸下滑动菜单顶部的黑色盖子?
在我的应用程序中,我有一个由开发的滑动菜单。 它在我的应用程序中运行良好;) 我有一个片段,它是MapView的宿主。这个片段和我从fragment类扩展的其他片段一样。就在这个片段中,当我打开滑动菜单时,菜单内容的顶部有一个黑色的封面/图层。当我在其他片段中打开菜单时,没有黑色封面。另外,我发现盒子的高度和碎片的高度完全一样 你以前见过这个问题吗?如有任何意见或建议,将不胜感激 => 更新 根据Selei的建议,我将背景设置为透明。但是,无论我指定什么颜色(透明或其他颜色),它仍然可见且为黑色:( 这是我的代码:Android 如何卸下滑动菜单顶部的黑色盖子?,android,slidingmenu,Android,Slidingmenu,在我的应用程序中,我有一个由开发的滑动菜单。 它在我的应用程序中运行良好;) 我有一个片段,它是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"/>
将MapView背景设置为透明-android:background=“#00000000”解决方案将map:zOrderOnTop=“true”
添加到XML
有关更多信息,请参阅。我刚刚创建了地图复制视图,当滑动菜单打开或关闭时,该视图将复制地图
@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);
}
}
ONOPTIONE已选定
@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);
}
}
我在这里尝试了所有方法,但没有一种效果很好。使用谷歌选项将zOrder移动到顶部意味着基本的缩放控制隐藏在地图后面。
此链接的最后一个建议:(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" />
感谢Mars,事实上我没有使用我的代码,因为它工作正常。我不认为这是因为代码,所有功能都是正确的。我想可能有人以前遇到过这个问题。我想应该是因为MapView。但我不确定:(嗨,你找到这个问题的解决方案了吗?非常感谢manThanks Selei,但它仍然可见。我已经在问题中添加了UI代码。请检查它。再次感谢;)问题是我不能在地图上添加任何东西,除了标记!!这很有效,谢谢!但我必须注释掉setRetainInstance(true)因为我得到了一个嵌套片段错误。我只对Build.VERSION.SDK_INT<11使用它
<?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" />
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();
}