ShowcaseView doesn't work without ActionBar

Is it possible to use ShowcaseView if the app has Theme.AppCompat.Light.NoActionBar and uses android.support. v7.widget.Toolbar in the app. I am getting below stack trace while running my application. Please suggest ...

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)

      

+3


source to share


4 answers


You cannot take a "tutorial step" pointing to a menu item if there is no ActionBar in the action (obviously why ... you don't have menu items).

If you want to center the circle in the view inside your activity / fragment, this should work for you.

ShowcaseView.Builder res = new ShowcaseView.Builder(activity, true)
                .setTarget(target)
                .setContentTitle("title")
                .setContentText("content");

      



Where is the goal:

Target target = new ViewTarget(view_id, activity)

      

+11


source


I solve my similar problem with this code (in a snippet):



        new ShowcaseView.Builder(getActivity())
    .setTarget( new ViewTarget( ((View) parentView.findViewById(R.id.link_to_register)) ) )
    .setContentTitle("ShowcaseView")
    .setContentText("This is highlighting the Home button")
    .hideOnTouchOutside()
    .build();

      

+9


source


if you want to show a hint in the overflowMenu you can try setting the following target using ShowCaseView # setTarget (Target t):

Target = new Target() {
    @Override
    public Point getPoint() {
        int[] location = new int[2];
        toolBar.getLocationInWindow(location);
        int x = location[0] + toolBar.getWidth() - toolBar.getHeight() / 2;
        int y = location[1] + toolBar.getHeight() / 2;
        return new Point(x, y);
    }
};

      

+1


source


It looks like the showcase doesn't work very well with Android Studio's quick deployment feature (possibly due to the use of reflation).

When I cleaned the project and restarted (after using the correct storefront constructor) it worked.

0


source







All Articles