应公司开发要求,需要实现第一次打开应用,对某一界面的一个或多个按钮或空间进行指示说明得功能。
通过对网上代码的改写,实现了该功能。
但由于不想依赖包套多的缘故,公司要求使用JAR包的方式,于是通过研究,将该功能集成成功。
下面是下载地址:ZXGuideUtil.jar
先放一下效果图
这是原始界面
这是显示第一个引导
第二个引导
这是引导文字在控件上方的情况
下面开始使用
使用前,你需要建立一个layout文件layout_guideview
代码如下
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/guide_text1"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:textColor="@color/color_white"
android:visibility="gone" />
<ImageView
android:id="@+id/guide_image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="@mipmap/arrow_up"
android:visibility="gone" />
<ImageView
android:id="@+id/guide_image2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="@mipmap/arrow_down"
android:visibility="gone" />
<TextView
android:id="@+id/guide_text2"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:textColor="@color/color_white"
android:visibility="gone" />
</LinearLayout>
该layout文件是引导层的说明及图片
以及两个图片,这个就不好上传了,我是下面这种
arrawUp.png
arrawDown.png
然后就可以了,下面是使用方法
LinearLayout mView = (LinearLayout) View.inflate(this, R.layout.layout_guideview, null);
ZXGuideBuilder zxGuideBuilder = new ZXGuideBuilder(GuideViewActivity.this, mView);
zxGuideBuilder.addList(tv, Component.ANCHOR_BOTTOM, "我我我我我我我我我我我我我我我我我我我我");
zxGuideBuilder.addList(btn, Component.ANCHOR_BOTTOM, "我我我我我我我我我我我我我我我我我我我我");
zxGuideBuilder.addList(et, Component.ANCHOR_BOTTOM, "我我我我我我我我我我我我我我我我我我我我");
zxGuideBuilder.addList(sw, Component.ANCHOR_TOP, "我我我我我我我我我我我我我我我我我我我我");
zxGuideBuilder.addList(cb, Component.ANCHOR_TOP, "我我我我我我我我我我我我我我我我我我我我");
zxGuideBuilder.show();
构造方法需要传两个参数,context和引导说明图片的view,就是我们刚刚引入的那个
addList方法,需要传入三个参数
View 需要显示引导界面的控件
Component类型的参数 一般来说使用ANCHOR_BOTTOM和ANCHOR_TOP,代表了引导箭头在控件上方还是下方
String 这个就是引导的文字
注意,addList的顺序决定了引导界面显示的顺序
最后记得Show一下就可以了
感谢您的阅读。