如果应用程序具有主题Theme.AppCompat.Light.NoActionBar并在应用程序中使用android.support.v7.widget.Toolbar,是否有任何方法可以使用ShowcaseView.我在执行应用程序时遇到堆栈跟踪.请建议......
java.lang.RuntimeException: insertShowcaseViewWithType cannot be used when the theme has no ActionBar
at com.github.amlcurran.showcaseview.targets.AppCompatReflector.getHomeButton(AppCompatReflector.java:32)
at com.github.amlcurran.showcaseview.targets.AppCompatReflector.getActionBarView(AppCompatReflector.java:20)
at com.github.amlcurran.showcaseview.targets.ActionViewTarget.setUp(ActionViewTarget.java:22)
at com.github.amlcurran.showcaseview.targets.ActionViewTarget.getPoint(ActionViewTarget.java:29)
at com.github.amlcurran.showcaseview.ShowcaseView$1.run(ShowcaseView.java:149)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
Run Code Online (Sandbox Code Playgroud) 我从这里使用ShowcaseView的最新版本
当我尝试将它与演示应用程序和活动一起使用时,它可以工作,但当我尝试将它与片段一起使用时,它崩溃了我的应用程序而没有logcat错误
@override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final ImageButton saveButton = (ImageButton) view.findViewById(R.id.button_Save);
ViewTarget viewTarget = new ViewTarget(saveButton);
showcaseView = new ShowcaseView.Builder(getActivity())
.setTarget(viewTarget)
.setContentTitle("Reset Button")
.setContentText("This will erase all the data in the table except the line that in progress")
.build();
}
Run Code Online (Sandbox Code Playgroud)
这可能是什么问题?
EDIT1:
当我尝试在我的片段活动中做同样的事情并且不起作用时,但是当我做同样的事情但是采取了在片段活动中声明的视图而不是在片段中它起作用.
EDIT2: 我设法从logcat中获取错误.
FATAL EXCEPTION: main
java.lang.IllegalArgumentException: width and height must be > 0
at android.graphics.Bitmap.createBitmap(Bitmap.java:724)
at android.graphics.Bitmap.createBitmap(Bitmap.java:703)
at android.graphics.Bitmap.createBitmap(Bitmap.java:670)
at com.github.amlcurran.showcaseview.ShowcaseView.updateBitmap(ShowcaseView.java:169)
at com.github.amlcurran.showcaseview.ShowcaseView.onGlobalLayout(ShowcaseView.java:343)
at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:839)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2050)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1249)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6364) …Run Code Online (Sandbox Code Playgroud)