A new user guide library in the scan box style on Android and a new android user

Source: Internet
Author: User

A new user guide library in the scan box style on Android and a new android user

Introduction

This is a new guide to the scan box style. The effect is as follows.

Use Gradle
compile 'com.yanzhikaijky:YGuider:0.9.2'
Supported features
  • Currently, only one scan box guide is supported (the multi-scan box is designed)
  • When a View object is input, the coordinate area is generated based on its location information and saved in the target area. (After the View object is passed in, the position is changed.startGuide()Call again beforeprepare())
  • You can also set the target for the left, top, right, and bottom coordinates of the input area.
  • You can customize the pop-up window layout.
  • You can customize the paint brush in the scan box.

    For detailed operation methods, refer to Wikipedia.

Usage Demo

The Demo already contains various poses for using YGuider, but some comments are missing. You are welcome to use Fork for experience. Pai_^

Easy to use

You need to input the Activity object to create YGuider, add the target to be scanned, and finally callprepare()The method is ready:

MYGuider = new YGuider (this); mYGuider. addNextTarget (new RectF (70, 70,170,170), "Click here to show all the text prompts immediately. Hello everyone, I'm YGuider! ", 90, 0); mYGuider. addNextTarget (btn1," the area is determined based on the input View! ", 150, 10); mYGuider. addNextTarget (new RectF (50,500,150,650)," it is determined based on the coordinates of the input rectangle region! ", 100, 10); mYGuider. addNextTarget (btn2," you can set an offset to control the position where PopupWindow appears and set its size! ",-350,-350,430, ViewGroup. layoutParams. WRAP_CONTENT); mYGuider. addNextTarget (new RectF (500,200,600,270), "can dynamically change the text of two buttons",-350, 50,300, ViewGroup. layoutParams. WRAP_CONTENT, "", "Finish"); mYGuider. prepare ();

Finally, usestartGuide()Method start:

                mYGuider.startGuide();
Method Introduction

Because there are too many methods, they are too occupied here, so please go to the Wiki to view the use of each method.

How to set the target
/*** Add a scan area * @ param targetView target View * @ param text description text * @ param wOffsetX the X position offset in the pop-up window (the initial position is in the middle of the target View) * @ param wOffsetY the Y position offset in the pop-up window (the initial position is at the bottom of the target View) */public void addNextTarget (View targetView, String text, int wOffsetX, int wOffsetY ); /*** Add a scan area * @ param targetView target View * @ param text description text * @ param wOffsetX the X position offset in the pop-up window (the initial position is in the middle of the target View) * @ param wOffsetY the Y position offset in the pop-up window (the initial position is at the bottom of the target View) * @ param wWidth the width of the pop-up window * @ param wHeight the height of the pop-up window */public void addNextTarget (View targetView, String text, int wOffsetX, int wOffsetY, int wWidth, int wHeight ); /*** Add a scan area * @ param targetView target View * @ param text description text * @ param wOffsetX the X position offset in the pop-up window (the initial position is in the middle of the target View) * @ param wOffsetY the Y position offset in the pop-up window (the initial position is at the bottom of the target View) * @ param wWidth the width of the pop-up window * @ param wHeight the height of the pop-up window * @ param jumpText skip option text * @ param nextText next option text */public void addNextTarget (View targetView, string text, int wOffsetX, int wOffsetY, int wWidth, int wHeight, String jumpText, String nextText ); /*** Add a scan area * @ param targetRegion coordinate matrix of the target area * @ param text description text * @ param wOffsetX the X position offset in the pop-up window (the initial position is in the middle of the target View)) * @ param wOffsetY the Y position offset in the pop-up window (the initial position is at the bottom of the target View) */public void addNextTarget (RectF targetRegion, String text, int wOffsetX, int wOffsetY ); /*** Add a scan area * @ param targetRegion coordinate matrix of the target area * @ param text description text * @ param wOffsetX the X position offset in the pop-up window (the initial position is in the middle of the target View)) * @ param wOffsetY the Y position offset in the pop-up window (the initial position is at the bottom of the target View) * @ param wWidth the width of the pop-up window * @ param wHeight the height of the pop-up window */public void addNextTarget (RectF targetRegion, String text, int wOffsetX, int wOffsetY, int wWidth, int wHeight ); /*** Add a scan area * @ param targetRegion coordinate matrix of the target area * @ param text description text * @ param wOffsetX the X position offset in the pop-up window (the initial position is in the middle of the target View)) * @ param wOffsetY the Y position offset in the pop-up window (the initial position is at the bottom of the target View) * @ param wWidth the width of the pop-up window * @ param wHeight the height of the pop-up window * @ param jumpText skip option text * @ param nextText next option text */public void addNextTarget (RectF targetRegion, string text, int wOffsetX, int wOffsetY, int wWidth, int wHeight, String jumpText, String nextText ); /*** add some Target * @ param targets some ScanTarget objects */public void addTarget (ScanTarget... targets );

Note: After the above add operation is executed, you mustprepare()In order for YGuider to obtain the location attribute of the target View.

/*** Start Guide */public void startGuide ();/*** enter the next Guide */public void startNextGuide (); /*** quit new user guide */public void cancelGuide (); /*** remove the target * @ param index * @ return: whether the target is successfully removed */public boolean removeTarget (int index ); /*** clear all scan targets */public void clearTargets ();/*** determine whether the width and height attributes have been initialized in the current ContentView * If yes, the location information of the target View is directly obtained. If not, write the target list *. After the ContentView class width and height attribute is initialized, obtain */public void prepare ();
How to Set Custom Attributes

These methods are used to set properties that have default values for YGuider, replace

/*** Set the interval for refreshing the scan box animation. The default value is 20 * @ param refreshTime. The unit is ms */public void setMaskRefreshTime (int refreshTime ); /*** set the animation duration for moving the scan box. The default value is 500 * @ param moveDuration. The unit is ms */public void setMaskMoveDuration (int moveDuration ); /*** set the duration of the expanded animation in the scan box. The default value is 500 * @ param expandDuration. The unit is ms */public void setExpandDuration (int expandDuration ); /*** set the color of the mask layer to transparent. The default color is # aa222222 * @ param color */public void setMaskColor (@ ColorInt int color ); /*** set the paint brush * @ param Paint paint brush */public void setMaskPaint (paint Paint);/*** set the speed at which TextView text appears in the pop-up window, the default value is 100 * @ param refreshTime. The unit is ms */public void setWindowTyperRefreshTime (int refreshTime). The text font size is displayed in the/*** pop-up window, the default value is 18sp * @ param size. The font size */public void setWindowTyperTextSize (int size);/*** sets the growth rate of TextView text in the pop-up window, the default value is 1 * @ param increase. How many characters are added each time */public void setWindowTyperIncrease (int increase ); /*** set the text of the Skip button * @ param jumpText skip text */public void setJumpText (String jumpText ); /*** set the text of the next button * @ param nextText next text */public void setNextText (String nextText ); /*** set the pop-up window background * @ param idRes background DrawableId */public void setWindowBackground (@ DrawableRes int idRes ); /*** set the text size of the Skip and next buttons * @ param size text font size */public void setWindowJumpAndNextTextSize (int size ); /*** set the custom pop-up window layout ** note that the new layout should have the TyperTextView class, And the id should be set to ttv_tips * you can select the Skip button and next button for implementation, if yes, set the id to TV _jump and TV _next respectively, and other IDs that can be customized * @ param layouId Layout */public void setWindowContent (@ LayoutRes int layouId );
About TyperTextView

This verbatim playback TextView is the TyperTextView in the HTextView I modified from hanks-zyh. It is a TextView, Text, TextSize, and TextColor that have been written in the code, these attributes can also be defined in the xml file.

Callback

YGuider Callbacks are classified into status callbacks.OnGuiderChangedListenerAnd click callbackOnGuiderClickListener:

/*** YGuider status change callback */public interface OnGuiderChangedListener {/*** callback at startup */void onGuiderStart (); /*** callback when redirecting to the next target * @ param nextIndex next target index */void onGuiderNext (int nextIndex ); /*** callback after boot completion */void onGuiderFinished ();}
/*** Call back various click events */public interface OnGuiderClickListener {/*** call back when the blank space of the mask layer is clicked */void onMaskClick (); /*** callback when the next button is clicked * @ param nextIndex next index */void onNextClick (int nextIndex ); /*** callback when the current highlight/scan target area is clicked * @ param index of the current target area */void onTargetClick (int index ); /*** callback when the Skip button is clicked */void onJumpClick ();}

Note: These are all interfaces. to implement them, you must override all the methods in them. Therefore, there is an abstract class that inherits them.OnGuiderListenerIf you implement its subclass, You can selectively override some callback methods (this design references the SimpleOnGestureDetector of GestureDetector), so there are the following methods to set the callback:

/*** Set click callback ** @ param guiderClickListener can be passed into the OnGuiderClickListener and OnGuiderListener subclasses */public void setOnGuiderClickListener (OnGuiderClickListener guiderClickListener) {mMask. setOnGuiderClickListener (guiderClickListener);}/*** set the status callback * @ param listener can be passed into the subclass of listener and OnGuiderListener */public void listener (onGuiderChangedListener OnGuiderChangedListener. callback (listener);}/*** all callback settings * @ param onGuiderListener sub-class of OnGuiderListener */public void setOnGuiderListener (OnGuiderListener onGuiderListener) {mMask. setOnGuiderListener (onGuiderListener );}

Source code: http://www.jinhusns.com/Products/Download

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.