透明指示层ShowTipsView实现教学指引效果

效果图看原帖
https://github.com/fredericojssilva/ShowTipsView

本人在其基础上
新增了方法:setCanceledOnTouchOutside(boolean),是否可以点击任意位置使ShowTipsView消失,默认为false
修改了不能显示半透明背景的bug,目前默认背景为半透明0x66000000,可通过setBackgroundColor(color)设置
其他地方的微调

使用方法:
Java代码   收藏代码
  1. ShowTipsView showtips = new ShowTipsBuilder(this)  
  2.         .setTarget(findViewById(R.id.btn_right))  
  3.         .setTitle("下一步")  
  4.         .setTitleColor(0xFFCCCC00)  
  5.         .setDescription("点击下一步就会进入下一页:)")  
  6.         .setDescriptionColor(0xFFFFFFFF)  
  7.         .setDelay(1000)  
  8.         .setBackgroundColor(0x66000000)  
  9.         .setCircleColor(0xFFFFFFFF)  
  10.         .setButtonText("知道了")  
  11.         .setCanceledOnTouchOutside(true)  
  12. //      .displayOneTime(0)  
  13.         .build();  
  14.   
  15.         showtips.setCallback(new ShowTipsViewInterface(){  
  16.             @Override  
  17.             public void onGotItClick() {  
  18.             }  
  19.   
  20.         });  
  21.         showtips.show(this);  

上面的示例代码中,ShowTipsView中能够设置的参数几乎全用到了
注意方法displayOneTime(int),一旦设置了该方法,ShowTipsView就不能重复显示了,因为一般来说,教学指引只在软件第一次安装运行后出现,无需每次运行软件的时候出现。
displayOneTime(int)的参数就是保存在SharedPreferences里的key,用于表示是否显示过,而不是指显示的次数。

具体的代码见附件,只要将其中的类copy到你的包里面即可使用
别忘了还有一个动画fade_in.xml
Xml代码   收藏代码
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <set xmlns:android="http://schemas.android.com/apk/res/android" >  
  3.   
  4.     <alpha  
  5.         android:duration="800"  
  6.         android:fromAlpha="0.0"  
  7.         android:interpolator="@android:anim/accelerate_interpolator"  
  8.         android:toAlpha="1.0" />  
  9.   
  10. </set>  




另一个类似的Android库:TourGuide
http://www.open-open.com/lib/view/open1437053882021.html

一个用于app指向性功能高亮的库
http://www.jcodecraeer.com/a/opensource/2015/1111/3675.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
和MaterialShowcaseView一样,也是用于用户第一次使用App时的使用方法引导控件。但是不如前者功能完善,至少没有引导链。还有,就是导入我的demo时,别忘了修改SDK的版本:android:targetSdkVersion="",改成你的,我用的是19项目地址:https://github.com/fredericojssilva/ShowTipsView 效果图:如何使用使用比较简单,你不需要修改原有的xml布局。比如我要对下列按钮添加引导:<Button         android:id="@ id/button1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignParentLeft="true"         android:layout_alignParentTop="true"         android:layout_marginLeft="58dp"         android:layout_marginTop="36dp"         android:text="Button" />java代码Button btn_one = (Button) findViewById(R.id.button1);          // ShowTipsView ShowTipsView showtips = new ShowTipsBuilder(this)                 .setTarget(btn_one).setTitle("A magnific button")                 .setDescription("This button do nothing very well")                 .setDelay(1000)//延时显示                 //.displayOneTime(2)//设置一个ID,整形的。如果设置了该属性,则只显示一次                 .build(); //showtips.setDisplayOneTime(true);//是否只显示一次 //showtips.setButtonText("我知道了");//设置按钮的文字,默认为"Got it" //设置回调 //showtips.setCallback(new ShowTipsViewInterface(){//当您点击"Got it"按钮后触发 //    @Override //    public void gotItClicked() {//设置回调让按钮2也产生引导,形成引导链 //  ShowTipsView showtips = new ShowTipsBuilder(MainActivity.this) //                .setTarget(btn_two).setTitle("A magnific button") //                .setDescription("This button do nothing very well") //                .setDelay(1000) //                .build(); //  showtips.show(MainActivity.this); //    }         // }); showtips.show(this);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值