3 回答
TA贡献1831条经验 获得超10个赞
通过在ViewPager内部a的顶部放置另一个具有透明背景的视图,我能够停止过渡后留下的黑色表面FrameLayout:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.view.ViewPager
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</android.support.v4.view.ViewPager>
<!-- hack to fix ugly black artefact with maps v2 -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent" />
</FrameLayout>
TA贡献1835条经验 获得超7个赞
SlidingMenu和ViewPager遇到相同的问题。我注意到地图片段中的控件按钮在左侧工件中不是黑色的。我通过覆盖onCreateView()方法解决了问题MapFragment (SupportMapFragment)
@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.FILL_PARENT,
LayoutParams.FILL_PARENT
)
);
return layout;
}
TA贡献1785条经验 获得超8个赞
Google为此发布了一个修复程序,但仅针对4.1+版本(您无需下载新版本的PlayServices,它们使用了服务器端标志)
这就是我用来绕过此问题的方法-确保您不会浪费任何CPU周期大于等于4.1的设备
public class FixMapFragment extends SupportMapFragment {
@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
// Fix for black background on devices < 4.1
if (android.os.Build.VERSION.SDK_INT <
android.os.Build.VERSION_CODES.JELLY_BEAN) {
setMapTransparent((ViewGroup) view);
}
return view;
}
private void setMapTransparent(ViewGroup group) {
int childCount = group.getChildCount();
for (int i = 0; i < childCount; i++) {
View child = group.getChildAt(i);
if (child instanceof ViewGroup) {
setMapTransparent((ViewGroup) child);
} else if (child instanceof SurfaceView) {
child.setBackgroundColor(0x00000000);
}
}
}
}
- 3 回答
- 0 关注
- 502 浏览
添加回答
举报