Android第三方框架之 引导蒙版TourGuide的使用

首先给上官方地址:

https://github.com/worker8/TourGuide#tooltip_customization

第一步:
在App的build.gradle中添加依赖:

dependencies {
compile ('com.github.worker8:tourguide:1.0.17-SNAPSHOT@aar') {
        transitive=true
    }
}
repositories {
    mavenCentral()
    maven() {
        url "https://oss.sonatype.org/content/repositories/snapshots"
    }
}

刚开始笔者看到没有repositories就将repositories后面的内容放到工程的build.gradle中,导致出错,之后sync一下ok了.
第二步:
初始化需要被依附的控件,我这里初始化了一个TextView一个Button,需要注意的TextView需要添加android:clickable=”true”才能响应点击事件.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="lwp.testguide.MainActivity">

    <TextView
        android:id="@+id/textview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:text="Hello World!" />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/button"
        android:text="hello"
        android:layout_centerInParent="true"/>
</RelativeLayout>
 button1= (Button) findViewById(R.id.button);
 textview = (TextView) findViewById(R.id.textview);

第三步:
设置引导版样式:

mTourGuideHandler = TourGuide.init(this).with(TourGuide.Technique.Click)
                .setPointer(new Pointer().setColor(Color.BLACK))
                .setToolTip(toolTip)
                .setOverlay(new Overlay())
                .playOn(button1);
toolTip = new ToolTip()
                .setTitle("Next Button")
                .setDescription("Click on Next button to proceed...")
                .setTextColor(Color.parseColor("#bdc3c7"))
                .setBackgroundColor(Color.parseColor("#e74c3c"))
                .setShadow(true)

                .setGravity(Gravity.TOP | Gravity.RIGHT)
                .setEnterAnimation(animation);

前面两个是固定写法,如果是在Fragment中使用的话,改this为getActivity即可,主要讲下setPointer,setToolTip,setOverlay这三个。
1.setPointer:顾名思义,就是设置点,什么点?依附在playOn的一个圆,如下图的白圆和红圆,可以通过setColor方法进行修改,此外还有一个方法setGravity,设置这个圆与依附控件的位置关系,默认是居中(center),设置左边就跑左边

这里写图片描述

2.setToolTip:设置提示的信息,如下图的”Welcome!”,”Click …”

这里写图片描述

这里通过一个toolTip,将设置与显示解耦,设置的信息看名字基本就能知道,我就不说了.

3.setOverlay:设置覆盖的颜色,样式,这个是覆盖除依附上的view以外的布局颜色,很炫,当然也可以自行设置如下:

Overlay overlay = new Overlay()
            .setBackgroundColor(Color.parseColor("#AAFF0000"))
            .disableClick(true)
            .setStyle(Overlay.Style.Rectangle);

不多说,自行感悟,很简单很强大。附上下载地址:
http://download.csdn.net/download/kururunga/9992037

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值