我使用这个库来展示导览。我想实现具有从未Menu Item
有过的属性的 Spotlight showAsAction
。在我的代码段下方:
View view = getActivity().findViewById(R.id.menu_item_refresh);
new SpotlightView.Builder(getActivity())
.introAnimationDuration(400)
.enableRevealAnimation(true)
.performClick(true)
.fadeinTextDuration(400)
.headingTvColor(Color.parseColor("#eb273f"))
.headingTvSize(32)
.headingTvText("")
.subHeadingTvColor(Color.parseColor("#ffffff"))
.subHeadingTvSize(16)
.subHeadingTvText("Tap on chart to show detail")
.maskColor(Color.parseColor("#dc000000"))
.target(view)
.lineAnimDuration(400)
.lineAndArcColor(Color.parseColor("#eb273f"))
.dismissOnTouch(true)
.dismissOnBackPress(true)
.enableDismissAfterShown(true)
.usageId("")
.show();
我收到此错误:
FATAL EXCEPTION: main
Process: x.com.d, PID: 15058
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.getLocationInWindow(int[])' on a null object reference
at com.wooplr.spotlight.target.ViewTarget.getPoint(ViewTarget.java:23)
at com.wooplr.spotlight.shape.Circle.getFocusPoint(Circle.java:36)
at com.wooplr.spotlight.shape.Circle.<init>(Circle.java:24)
at com.wooplr.spotlight.SpotlightView$Builder.build(SpotlightView.java:1082)
at com.wooplr.spotlight.SpotlightView$Builder.show(SpotlightView.java:1091)
我看到错误发生了,因为Menu Item
在主视图上是不可见的。我读了这个相关的问题,但我仍然得到同样的错误。是否有可能获得不可见的项目(从不作为行动)?