Android 引導頁面NewbieGuide的使用
做開發很多的時候都會用到引導頁面,今天記錄一個比較好用的引導頁面NewbieGuide的使用,自己公司的項目中也用到了,在這裡面做下記錄。
上圖

導入依賴
implementation 'com.github.huburt-Hu:NewbieGuide:v2.4.0’
給一個github的位址
接下來就是簡單的使用我上面面的例子來說。
private void initGuideView() {
Animation enterAnimation = new AlphaAnimation(0f, 1f);
enterAnimation.setDuration(600);
enterAnimation.setFillAfter(true);
Animation exitAnimation = new AlphaAnimation(1f, 0f);
exitAnimation.setDuration(600);
exitAnimation.setFillAfter(true);
NewbieGuide.with((Activity) context)
.setLabel("one")
.addGuidePage(GuidePage.newInstance()
.setLayoutRes(R.layout.wbf_test_guide, R.id.sss) //自定義的布局
.setEverywhereCancelable(false)//是否點選任意位置消失引導頁,預設true
.setBackgroundColor(0xd8000000) // 設定背景顔色
.addHighLight(sss, HighLight.Shape.ROUND_RECTANGLE, 0, 20, null)
//(高亮的控件,高亮的形狀這個是方形,圓角的大小,高亮相對view的padding,相對于高亮的引導布局)
.setEnterAnimation(enterAnimation) //設定動畫
.setExitAnimation(exitAnimation)
)
.setOnGuideChangedListener(new OnGuideChangedListener() {
@Override
public void onShowed(Controller controller) {
//顯示的監聽
}
@Override
public void onRemoved(Controller controller) {
//消失的監聽
}
})
.addGuidePage(GuidePage.newInstance()
.setLayoutRes(R.layout.wbf_test_guide_two, R.id.guideone)
.setEverywhereCancelable(false)
.setBackgroundColor(0xd8000000)
.addHighLight(guideone, HighLight.Shape.ROUND_RECTANGLE, 50, 35, null)
.setEnterAnimation(enterAnimation)
.setExitAnimation(exitAnimation)
)
.setOnPageChangedListener(new OnPageChangedListener() {
@Override
public void onPageChanged(int page) {
//這個是頁數的監聽
}
})
.addGuidePage(GuidePage.newInstance()
.setLayoutRes(R.layout.wbf_test_guide_three, R.id.guidetwo)
.setEverywhereCancelable(false)
.setBackgroundColor(0xd8000000)
.addHighLight(guidetwo, HighLight.Shape.CIRCLE, 50, 35, null)
.setEnterAnimation(enterAnimation)
.setExitAnimation(exitAnimation)
)
.setOnGuideChangedListener(new OnGuideChangedListener() {
@Override
public void onShowed(Controller controller) {
}
@Override
public void onRemoved(Controller controller) {
}
})
//true 新手引導總是顯示 false 隻顯示一次
.alwaysShow(true)
.show();
}
基本上就沒有什麼了。。。用法很簡單
給上一個我代碼的連結