Android:ShowCase View只显示一次并重复动画

Mok*_*pps 3 android android-animation android-fragments showcaseview

我在我的片段中使用ShowCase View库.我展示了一个手势动画,应该重复,直到用户按下OK按钮.但只显示一次.

每次创建片段时都会显示展示,而不仅仅是一次.

我的代码看起来像这样:

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);
        }
Run Code Online (Sandbox Code Playgroud)

使用的布局:

<?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>
Run Code Online (Sandbox Code Playgroud)

Mok*_*pps 6

我这样解决了:

  1. 安装后只执行一次我跟着这篇文章.
  2. 为了重复动画,我使用了这篇文章中提供的代码.

现在,ShowcaseView仅在安装后出现一次,只要未单击该按钮,就会显示手势动画.