我希望始终将ImageView
显示在最前面。此ImageView
位于Fragment
。
但是,我收到了一条错误消息。
java.lang.IllegalArgumentException: view must not be null
这是我的代码。
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mContext = getActivity().getApplicationContext();
View rootView = inflater.inflate(R.layout.fragment_mapview, container, false);
mImageFloor = (ImageView) rootView.findViewById(R.id.img_floor);
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
PixelFormat.TRANSLUCENT);
WindowManager wm = (WindowManager) getActivity().getSystemService(mContext.WINDOW_SERVICE);
wm.addView(mImageFloor, params); // *This line has an error
我做错了吗?