An Android GuideView for step by step to lead users.
Refer to repertory:GuideView of laxian. By the way, thanks laxin who has share this awesome GuideView.
This repertory is an enhanced edition.
This GuideView need a target view and a tips view:
- target view: you want to focus on it.
- tips view: the tips will show when ui focus on the target view.
GuideView.Builder guideWiewBuilder = new GuideView.Builder(activitycontext);
GuideView guideView = guideWiewBuilder.create()
or
GuideView guideView = new GuideView.Builder(activitycontext).create();
Here are two methods can set target view.
- targetView(View view)
- targetView(R.id.viewId)
Here are two methods can set target view.
- tipsView(view)
- tipsView(R.layout.layoutId)
- isShouldClickFocus(boolean)
Set if need to click the target view to dismiss the GuidView or not. Default value is true. - isRealClickFocus(boolean)
Set if need to real click the target view to dissmiss and it will callback the target view's OnClickListenter or onTouchEvent. Defaul is false
Attention:
Set isRealClickFocus true required the value of isShouldClickFocus is true, otherwise it won't work
- shape(shapeType) default shape type is CIRCLE.
ShapeTypes values
- SHAPE_CIRCLE
- SHAPE_OVAL
- SHAPE_RECTANGLE (including round rectangle)
You can set the radian attribute to make a round retangle.
You can set the roundRectOffset attribute control the order offset.
This offset is for tips view relative to target view on x,y axis,default values is zero.
- offsetX(int)
- offsetY(int)
This layout gravity is relative to target view.
- layoutGravity(gravityInt) default value is Gravity.NO_GRAVITY
Values
- Gravity.LEFT
- Gravity.TOP
- Gravity.RIGHT
- Gravity.BOTTOM
- Gravity.NO_GRAVITY
bgColor(colorInt) default color is #b0000000
- blurRadius(float)
Control to the blur effect on target view. Default is zero. It will work if bigger than zero.
- focusToShake(boolean)
Control if need to shake the focus part on target view. It will cost some cpu,gpu consumption. Default value is false.
Callback for dismiss.
onDismissListener(new GuideView.OnDismissListener() {
@Override
public void onDismiss() {
//do your things
}
})
or use GuidView
guideView.setOnDismissListener(new GuideView.OnDismissListener() {
@Override
public void onDismiss() {
//do your things
}
});
GuideView guideView = new GuideView.Builder(activitycontext)
.bgColor(Color.parseColor("#b0239823"))
.blurRadius(5)
.targetView(tv2)
.tipsView(createTextView())
// .isShouldClickFocus(false)
// .isRealClickFocus(true)
.shape(GuideView.SHAPE_RECTANGLE)
//.focusToShake(true)
//.radian(10)
//.roundRectOffset(30)
.offsetY(20)
.layoutGravity(Gravity.BOTTOM)
// .onDismissListener(new GuideView.OnDismissListener() {
// @Override
// public void onDismiss() {
// Log.e("setOnDismissListener","dismiss");
// }
// })
//
.create();
GuideViewQueue is a static queue for guideviews.It will show every GuideView you have added in order and finally callback the OnFinallyDismissListener,it will be null when its jobs is done.
Here is a sample below:
GuideViewQueue guideViewQueue = GuideViewQueue.getInstance();
guideViewQueue.add(new GuideView.Builder(this).targetView(tv1).tipsView(createTextView())
.shape(GuideView.SHAPE_OVAL).create());
guideViewQueue.add(new GuideView.Builder(this).targetView(tv2).tipsView(R.layout.layout_linearlayout)
.layoutGravity(Gravity.BOTTOM).create());
guideViewQueue.add(new GuideView.Builder(this).targetView(ll3).tipsView(createTextView())
.shape(GuideView.SHAPE_RECTANGLE).radian(10).roundRectOffset(10).create());
guideViewQueue.setOnCompleteDismissListener(new GuideViewQueue.OnCompleteDismissListener() {
@Override
public void onDismiss() {
Log.e("GuideViewQueue","finally dimiss");
}
});
guideViewQueue.show();