huburt-hu / newbieguide Goto Github PK
View Code? Open in Web Editor NEWAndroid 快速实现新手引导层的库,通过简洁链式调用,一行代码实现引导层的显示
License: Apache License 2.0
Android 快速实现新手引导层的库,通过简洁链式调用,一行代码实现引导层的显示
License: Apache License 2.0
window.setStatusBarColor(Color.TRANSPARENT); 加了之后,即使在.fullScreen(true) 仍然没用
如题,这个库运行在不同机型上,高亮和[setLayoutRes(R.layout.view_guide)] #,有些机型显示正常,有些机型位置显示错乱
版本:1.1.1
调用:在主界面的底部按钮点击事件中
@OnClick({R.id.ll_tab_task, R.id.ll_tab_master, R.id.ll_tab_me})
public void onTabClick(final View view) {
if (view.getId() == R.id.ll_tab_task) {
new Thread(new Runnable() {
@Override
public void run() {
SystemClock.sleep(768);
if (isFinishing()) return;
llTabTask.post(new Runnable() {
@Override
public void run() {
Controller controller = NewbieGuide.with(MainTabActivity.this)//传入activity
.setOnGuideChangedListener(new OnGuideChangedListener() {
@Override
public void onShowed(final Controller controller) {
// 获取布局,然后查找其中的文本按钮,并设置点击事件
GuideLayout layout = ViewUtils.getGuideLayout(controller);
if (layout == null || layout.findViewById(R.id.tv_known) == null) return;
TextView tvKnown = layout.findViewById(R.id.tv_known);
tvKnown.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
controller.remove();
}
});
}
@Override
public void onRemoved(Controller controller) {
onTabClick(tabs.get(1));
}
})
.setLabel(Consts.Config.GUIDE_LABEL_SHARE2EARN)//设置引导层标示,用于区分不同引导层,必传!否则报错
.addHighLight(llTabTask, HighLight.Type.CIRCLE)//添加需要高亮的view
.setLayoutRes(R.layout.guide_newbie_task)//自定义的提示layout,不要添加背景色,引导层背景色通过setBackgroundColor()设置
.setEveryWhereCancelable(Consts.Config.GUIDE_NEWBIE_CLICK_ANYWHERE)
.alwaysShow(Consts.Config.GUIDE_NEWBIE_SHOW_ALWAYS)
.build();
controller.show();//显示引导层
}
});
}
}).start();
}
}
日志信息:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.toudeng.ddzh/com.toudeng.ddzh.activity.MainTabActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2464)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2526)
at android.app.ActivityThread.access$800(ActivityThread.java:174)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1398)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:229)
at android.app.ActivityThread.main(ActivityThread.java:5493)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:676)
at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException
at com.app.hubert.library.V4ListenerFragment.onStart(V4ListenerFragment.java)
at android.support.v4.app.Fragment.performStart(Fragment.java)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java)
at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java)
at android.support.v4.app.FragmentManagerImpl.dispatchStart(FragmentManager.java)
at android.support.v4.app.Fragment.performStart(Fragment.java)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java)
at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java)
at android.support.v4.app.FragmentManagerImpl.dispatchStart(FragmentManager.java)
at android.support.v4.app.FragmentController.dispatchStart(FragmentController.java)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java)
at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1174)
at android.app.Activity.performStart(Activity.java:5473)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2427)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2526)
at android.app.ActivityThread.access$800(ActivityThread.java:174)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1398)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:229)
at android.app.ActivityThread.main(ActivityThread.java:5493)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:676)
at dalvik.system.NativeStart.main(Native Method)
你好,有多个引导页,如果我想从第二页出发引导页某控件进入第一页引导页,有方法提供吗(Hello, there are more than one guide page, if I want to start from the second page to the first page, is there a method to provide?)
请问博主怎么设置高亮view的自定义点击事件呢 ? 如果设置透明view的话有些机子透明view位置对不齐
fragment中设置alwaysShow(false),一次都不显示,请问一下是什么原因?
设置绘制矩形、圆、椭圆 区域的点击事件
楼主,我需要在指向一个GridView中的一个item高亮。
通过adapter的getview方法找到convertView然后addHighlight的。貌似没效果?
用convertView.findViewById找到子View也不行。
` mWxStoreView = mCateNameGridViewAdapter.getView(0, null, null);
ImageView icon = (ImageView)
mWxStoreView.findViewById(R.id.id_home_cate_name_gridview_img);
NewbieGuide.with(getActivity())//传入fragment .setLabel("guide2")//设置引导层标示,必传!否则报错
.addHighLight(mWxStoreView , HighLight.Type.RECTANGLE)//添加需要高亮的view
.addHighLight(loopViewPager, HighLight.Type.RECTANGLE)//添加需要高亮的view
.setLayoutRes(R.layout.view_guide)//自定义的提示layout,不要添加背景色,引导层背景色通过setBackgroundColor()设置
.alwaysShow(true)
.show();//直接显示引导层`
alwaysShow(true),每次都显示了,这个是符合文档说明的
alwaysShow(false),第一次也没显示啊,还需要别的参数设置么?
高亮的位置偏离实际位位置,表现为高亮的区域比需要高亮的view的位置上移一个状态栏的高度
楼主你好,我在引入这个依赖包之后,
产生了以下错误
Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.
Error:(4) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.
Error:(4) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: Failed to execute aapt
通过
View view = layoutManager.findViewByPosition(3);
或者
View view = mRecyclerView.getChildAt(3);
得到的view放到addHighLight里,
不能使具体的itemview高亮,直接APP无响应了卡死了。
提问前,先完成以下步骤:
1.仔细阅读README的使用示例;
2.查看Wiki中的Q&A;
3.搜索Issues历史;
如果还没有找到你问题的解决方案,再提Issues,谢谢!
在Controller.java中添加
guideLayout.setLayerType(View.LAYER_TYPE_HARDWARE, null)
可以解决
应该是MIUI这个版本默认给View开启硬件加速的原因
另:如果还是无法显示 尝试给guidelayout里面的View也关闭硬件加速,我是两个地方都加了的
放在有百度地图上面,点击取消不了
@kong-jing @huburt-Hu
出现引导层后,底层布局里的scrollview依然可以滑动
NewbieGuide.with(FirstActivity.this)
.setLabel("anchor")
.anchor(anchorView)
.alwaysShow(true)//总是显示,调试时可以打开
.addGuidePage(GuidePage.newInstance()
.addHighLight(btnAnchor, HighLight.Shape.CIRCLE, 1195)
.setLayoutRes(R.layout.view_guide_anchor))
.show();
你好,请看看
能知道大概位置,不过没法获取到那个view 咋整
}).alwaysShow(false)//是否每次都显示,false为第一次显示
compile ('com.github.huburt-Hu:NewbieGuide:v2.0.0') {
exclude group: 'com.android.support'
}
v2.1.0修改了Controller.java中label的SharedPreferences存储类型为int,之前版本为boolean。如果从之前版本升级到v2.1.0,会报一下错误:
java.lang.ClassCastExcetion:java.lang.Boolean cannot be cast to java.lang.Integer;
修改label与旧版本不一致可解决。希望在readme中备注下。
感谢分享!1.x升级2.x思路更清晰了,期待更新
感谢楼主这个库,用了之后用引导页,的确省事好多.
但是使用过程中,当想实现一个一个显示不同引导页的时候,用现有库开放的Api,接口实现起来代码比较重复.(OnGuideChangedListener.onRemoved 的时候显示下一个Controller)
建议下一版本可以考虑添加管理多个Controller的控制类
如何指向recyclerview某一个item
NewbieGuide.with(getActivity())
.setLabel("guide1")
.addGuidePage(GuidePage.newInstance()
.addHighLight(llayout_novice_welfare)
.setLayoutRes(R.layout.view_guide_simple))
.show();
demo中的代码 直接复制过去都没用
rt
底层布局是scrollview,调用scrollTo后,高亮的位置不变,有什么解决办法吗?
fragment中可以使用吗?
1.fragment中的自定义view
2.通过自定义view获取控件
3.用作者的代码为这个控件设置高亮
不显示 但是点击任意消息时候 显示了一瞬间 我设置了进入/退出的动画
不知道什么原因
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.