神刀安全网

ShowcaseView for Android

ShowcaseView

ShowcaseView for Android ShowcaseView for Android ShowcaseView for Android

This ShowcaseView library can be used to showcase any specific part of the UI or can even be used during OnBoarding of a user to give a short intro about different widgets visible on the screen. You may add any number of views (ImageView, TextView, FrameLayout, etc displaying images, videos, GIF, text etc) to describe the showcasing view.

Usage

For a working implementation of this project see the /app folder

  1. Include the library as local library project or add this dependency in your build.gradle.

             dependencies {           compile 'com.outlander.showcaseview:showcaseview:1.1.3'         }       
  2. Initialise the ShowcaseViewBuilder as follows:

             ShowcaseViewBuilder showcaseViewBuilder;         ...         showcaseViewBuilder = ShowcaseViewBuilder.init(this)                 .setTargetView(fab)                 .setBackgroundOverlayColor(0xdd4d4d4d)                 .setRingColor(0xcc8e8e8e)                 .setRingWidth(20)                 .setMarkerDrawable(getResources().getDrawable(R.drawable.arrow_up), Gravity.LEFT)                 .addCustomView(R.layout.description_view, Gravity.TOP)                 .addCustomView(R.layout.skip_layout)                 .setCustomViewMargin(70);                  showcaseViewBuilder.show();       
  3. Register click listeners on the customView added as follows:

               showcaseViewBuilder.setClickListenerOnView(R.id.exit_btn, new View.OnClickListener() {             @Override             public void onClick(View v) {                 //TODO: Add thing to do when clicked.             }           });         
  4. To hide the showcaseView just call:

               showcaseViewBuilder.hide()         
  5. To hide the showcaseView when user clicks on the overlay, just set the following flag: showcaseViewBuilder.setHideOnTouchOutside(true); By default, this is always false.

Things to keep in mind

  • Call the showcaseViewBuilder.show() only after adding all the customViews and MarkerDrawable.

  • Once showcaseViewBuilder.hide() is called, all the click listeners get deregistered . Thus, you will have to set them back if showing it again. Better to register all the click listeners in a single method which can be called when showing the showcaseView.

Method Definitions

  • setTargetView(View v) : Sets the view which needs to be showcased.

  • setBackgroundOverlayColor(int color) : Sets the color of the overlay to be shown.

  • setRingColor(int color) : Sets the color of the ring around the showcaseView.

  • setRingWidth(float width) : Sets the width of the ring around the showcaseView. Default value is 10px

  • setMarkerDrawable(Drawable drawable, int gravity) : Sets the marker drawable if any to point the showcaseView. Also, sets a gravity for the drawable (TOP, LEFT, RIGHT, BOTTOM) around the showcasing view.

  • setDrawableLeftMargin(float margin) : Sets the marker drawable left margin.

  • setDrawableTopMargin(float margin) : Sets the marker drawable top margin.

  • addCustomView(View view, int gravity) : Sets the custom description view to describe the showcaseView. Also, sets a gravity for the view (TOP, LEFT, RIGHT, BOTTOM) around the showcasing view.

  • addCustomView(View view) : Sets the custom description view to describe the showcaseView. This doesn’t takes any gravity as an argument and renders the view as per the gravity defined in the layout file.

  • setCustomViewMargin(int margin) : Sets the custom description view margin from the showcaseView in the direction of the gravity defined, if any. If no gravity defined, then no point in using this method.

  • setHideOnTouchOutside(boolean hide) : Sets the flag which decide whether to hide the showcase overlay when user touches on the screen anywhere.

  • setClickListenerOnView(int id, View.OnClickListener clickListener) : Sets clicklistener on the components of the customView(s) added.

  • show() : Start showcasing the targetView.

  • hide() : Stop showcasing the targetView.

Developed by

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » ShowcaseView for Android

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址