Question

I am using ShowCase View library in my fragments. I show a gesture animation which should be repeated until the user presses the OK button. But is only shown once.

Also the showcase is shown every time the Fragment is created and not only once.

My code looks like this:

public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        //get display size for slide over screen
        Display display = getActivity().getWindowManager().getDefaultDisplay();
        Point p = new Point();
        display.getSize(p);

        if(!is_tablet()){
            // ShowView Tutorial if on smartphone
            ViewTarget target = new ViewTarget(getView());
            ShowcaseView.ConfigOptions co = new ShowcaseView.ConfigOptions();
            //can only dismiss by button click
            co.hideOnClickOutside = false;
            //show only once
            co.shotType = ShowcaseView.TYPE_ONE_SHOT;
            sv = ShowcaseView.insertShowcaseView(target, getActivity(),
                    R.string.showcase_detail_title, R.string.showcase_detail_message,co);
            // remove circle
            sv.setShowcaseIndicatorScale(0);
            // set black background
            sv.setBackgroundColor(getResources().getColor(R.color.black));
            // make background a bit transparent
            sv.setAlpha(0.9f);
            // show PullToRefreshGesture
            sv.animateGesture(0, p.y / 2, p.x, p.y / 2);
        }

The used layout:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<mypackage.PullToRefresh.PullToRefreshListView
android:id="@id/android:list"
android:layout_height="match_parent"
android:layout_width="match_parent" 
android:divider="@android:color/transparent"
android:dividerHeight="10dp"
android:layout_margin="10dp"/>

</LinearLayout>
Was it helpful?

Solution

I solved it this way:

  1. To execute it only once after the installation I followed this post.
  2. To repeat the animation I used the code provided in this post.

Now the ShowcaseView only appears once after the installation and the gesture animation is shown as long as the button is not clicked.

OTHER TIPS

 /**
     * Set the ShowcaseView to only ever show once.
     *
     * @param shotId a unique identifier (<em>across the app</em>) to store
     *               whether this ShowcaseView has been shown.
     */
    public Builder singleShot(long shotId) {
        showcaseView.setSingleShot(shotId);
        return this;
    }

To repeat animation with times:

sv.setRepeatCount(number);

For infinite:

sv.setRepeatCount(Animation.INFINITE);
sv.setRepeatMode(Animation.INFINITE);

and in your layout:

android:repeatMode="reverse"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top