3

フラグメントでShowCase View ライブラリを使用しています。ユーザーが OK ボタンを押すまで繰り返されるジェスチャー アニメーションを表示します。ただし、表示されるのは 1 回のみです。

また、ショーケースは一度だけではなく、フラグメントが作成されるたびに表示されます。

私のコードは次のようになります。

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);
        }

使用されたレイアウト:

<?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>
4

3 に答える 3

6

私はこのように解決しました:

  1. インストール後に一度だけ実行するには、この投稿に従いました。
  2. アニメーションを繰り返すために、この投稿で提供されているコードを使用しました。

ShowcaseView はインストール後に 1 回だけ表示され、ボタンがクリックされない限りジェスチャー アニメーションが表示されるようになりました。

于 2014-01-24T14:54:44.493 に答える
2
 /**
     * 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;
    }
于 2016-01-30T03:30:35.143 に答える
0

時間を指定してアニメーションを繰り返すには:

sv.setRepeatCount(number);

無限の場合:

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

そしてあなたのレイアウトで:

android:repeatMode="reverse"
于 2014-01-21T07:29:46.767 に答える