框架整理系列二十二(新手引導)[廢]

感謝大神:https://github.com/worker8/TourGuide
感謝大神:https://github.com/TakuSemba/Spotlight

TourGuide

Demo

Demo
Demo

How to setup

Add the below dependencies into your gradle file:

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

MinSDK Version

The minimum SDK version required by TourGuide is API Level 11+ (Android 3.0.x, HONEYCOMB).

How to use

Basic

Let's say you have a button like this where you want user to click on:

Button button = (Button)findViewById(R.id.button);

You can add the tutorial pointer on top of it by:

TourGuide mTourGuideHandler = TourGuide.init(this).with(TourGuide.Technique.Click)
            .setPointer(new Pointer())
            .setToolTip(new ToolTip().setTitle("Welcome!").setDescription("Click on Get Started to begin..."))
            .setOverlay(new Overlay())
            .playOn(button);
  • setPointer() - This describe how the Pointer will look like, refer to Pointer Customization Guide on how to change the appearance, null can be passed in if a Pointer is not wanted.
  • setToolTip - This describe how the ToolTip will look like, refer to ToolTip Customization Guide on how to change the appearance, null can be passed in if a ToolTip is not wanted.
  • setOverlay - This describe how the Overlay will look like, refer to Overlay Customization Guide on how to change the appearance, null can be passed in if an Overlay is not wanted.
  • with - Use TourGuide.Technique.Click for the moment, this will be removed in the future.
  • mTourGuideHandler - The return type is a handler to be used for clean up purpose.

When the user is done, you can dismiss the tutorial by calling:

mTourGuideHandler.cleanUp();

<a name="tooltip_customization"></a>ToolTip Customization Guide

Tooltip is the box of text that gives further explanation of a UI element. In the basic example above, the ToolTip not customized, so the default style is used. However, you can customize it if you wish to.

Animation animation = new TranslateAnimation(0f, 0f, 200f, 0f);
animation.setDuration(1000);
animation.setFillAfter(true);
animation.setInterpolator(new BounceInterpolator());

ToolTip 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.LEFT)
                    .setEnterAnimation(animation);

TourGuide mTourGuideHandler = TourGuide.init(this).with(TourGuide.Technique.Click)
            .setPointer(new Pointer())
            .setToolTip(toolTip)
            .setOverlay(new Overlay())
            .playOn(button);

Most of the customization methods/parameters are self-explanatory, except gravity that deserves a mention. gravity is relative to targetted button where TourGuide playOn(). For example .setGravity(Gravity.TOP | Gravity.LEFT) will produce the following:

ToolTip gravity

<a name="pointer_customization"></a>Pointer Customization Guide

Pointer is the round button that is animating to indicate the clickable UI element. The default color is white and the default gravity is center. You can customize it by:

new Pointer().setColor(Color.RED).setGravity(Gravity.BOTTOM|Gravity.RIGHT);

This is a comparison with and without the customization:

Pointer Customization

<a name="overlay_customization"></a>Overlay Customization Guide

Overlay is the semi-transparent background that is used to cover up other UI elements so that users can take focus on what to click on. The color and shape can be customized by:

Overlay overlay = new Overlay()
            .setBackgroundColor(Color.parseColor("#AAFF0000"))
            .disableClick(true)
            .setStyle(Overlay.Style.Rectangle);
  • disableClick(true) will make elements covered by the overlay to become unclickable. Refer to Overlay Customization Activity in the example.
  • .setStyle() Currently only 2 styles are available: Overlay.Style.Rectangle and Overlay.Style.Circle

Running TourGuide in Sequence

Running TourGuide in sequence is a very common use case where you want to show a few buttons in a row instead of just one. Running in sequence can be subdivided into 2 use cases:

最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末舵抹,一起剝皮案震驚了整個濱河市弧哎,隨后出現(xiàn)的幾起案子殴泰,更是在濱河造成了極大的恐慌,老刑警劉巖木蹬,帶你破解...
    沈念sama閱讀 221,695評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件换团,死亡現(xiàn)場離奇詭異第步,居然都是意外死亡,警方通過查閱死者的電腦和手機阅虫,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,569評論 3 399
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來不跟,“玉大人颓帝,你說我怎么就攤上這事。” “怎么了购城?”我有些...
    開封第一講書人閱讀 168,130評論 0 360
  • 文/不壞的土叔 我叫張陵吕座,是天一觀的道長。 經(jīng)常有香客問我瘪板,道長吴趴,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,648評論 1 297
  • 正文 為了忘掉前任侮攀,我火速辦了婚禮锣枝,結果婚禮上,老公的妹妹穿的比我還像新娘兰英。我一直安慰自己撇叁,他們只是感情好,可當我...
    茶點故事閱讀 68,655評論 6 397
  • 文/花漫 我一把揭開白布畦贸。 她就那樣靜靜地躺著陨闹,像睡著了一般。 火紅的嫁衣襯著肌膚如雪家制。 梳的紋絲不亂的頭發(fā)上正林,一...
    開封第一講書人閱讀 52,268評論 1 309
  • 那天,我揣著相機與錄音颤殴,去河邊找鬼觅廓。 笑死,一個胖子當著我的面吹牛涵但,可吹牛的內(nèi)容都是我干的杈绸。 我是一名探鬼主播,決...
    沈念sama閱讀 40,835評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼矮瘟,長吁一口氣:“原來是場噩夢啊……” “哼瞳脓!你這毒婦竟也來了?” 一聲冷哼從身側響起澈侠,我...
    開封第一講書人閱讀 39,740評論 0 276
  • 序言:老撾萬榮一對情侶失蹤劫侧,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后哨啃,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體烧栋,經(jīng)...
    沈念sama閱讀 46,286評論 1 318
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,375評論 3 340
  • 正文 我和宋清朗相戀三年拳球,在試婚紗的時候發(fā)現(xiàn)自己被綠了审姓。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,505評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡祝峻,死狀恐怖魔吐,靈堂內(nèi)的尸體忽然破棺而出扎筒,到底是詐尸還是另有隱情,我是刑警寧澤酬姆,帶...
    沈念sama閱讀 36,185評論 5 350
  • 正文 年R本政府宣布嗜桌,位于F島的核電站,受9級特大地震影響轴踱,放射性物質發(fā)生泄漏症脂。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,873評論 3 333
  • 文/蒙蒙 一淫僻、第九天 我趴在偏房一處隱蔽的房頂上張望诱篷。 院中可真熱鬧,春花似錦雳灵、人聲如沸棕所。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,357評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽琳省。三九已至,卻和暖如春躲撰,著一層夾襖步出監(jiān)牢的瞬間针贬,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,466評論 1 272
  • 我被黑心中介騙來泰國打工拢蛋, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留桦他,地道東北人。 一個月前我還...
    沈念sama閱讀 48,921評論 3 376
  • 正文 我出身青樓谆棱,卻偏偏與公主長得像快压,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子垃瞧,可洞房花燭夜當晚...
    茶點故事閱讀 45,515評論 2 359

推薦閱讀更多精彩內(nèi)容