制作锁屏中经常用到的上滑左滑右滑下滑任意滑动解锁代码整理:
<!-- 上滑解锁 -->
<Unlocker name="unlocker" alwaysShow="true" bounceInitSpeed="2000" bounceAccelation="1500" >
<StartPoint x="0" y="0" w="#screen_width" h="#screen_height">
<NormalState></NormalState>
</StartPoint>
<EndPoint x="0" y="-#screen_height-300" w="#screen_width" h="#screen_height">
<Path x="0" y="0" tolerance="2000">
<Position x="0" y="0" />
<Position x="0" y="-#screen_height" />
</Path>
</EndPoint>
</Unlocker>
<!-- 下滑解锁 -->
<Unlocker name="unlocker" alwaysShow="true" bounceInitSpeed="2000" bounceAccelation="1500" >
<StartPoint x="0" y="0" w="#screen_width" h="#screen_height">
<NormalState></NormalState>
</StartPoint>
<EndPoint x="0" y="300" w="#screen_width" h="#screen_height">
<Path x="0" y="0" tolerance="2000">
<Position x="0" y="0" />
<Position x="0" y="#screen_height" />
</Path>
</EndPoint>
</Unlocker>
<!-- 右滑解锁 -->
<Unlocker name="unlocker" alwaysShow="true" bounceInitSpeed="2000" bounceAccelation="1500" >
<StartPoint x="0" y="0" w="#screen_width" h="#screen_height">
<NormalState></NormalState>
</StartPoint>
<EndPoint x="300" y="0" w="#screen_width" h="#screen_height">
<Path x="0" y="0" tolerance="1500">
<Position x="0" y="0" />
<Position x="#screen_width" y="0" />
</Path>
</EndPoint>
</Unlocker>
<!-- 左滑解锁 -->
<Unlocker name="unlocker" alwaysShow="true" bounceInitSpeed="2000" bounceAccelation="1500" >
<StartPoint x="0" y="0" w="#screen_width" h="#screen_height">
<NormalState></NormalState>
</StartPoint>
<EndPoint x="-#screen_width-300" y="0" w="#screen_width" h="#screen_height">
<Path x="0" y="0" tolerance="1500">
<Position x="0" y="0" />
<Position x="-#screen_width" y="0" />
</Path>
</EndPoint>
</Unlocker>
<!-- 任意滑动解锁 -->
<Var name="unlock_dist" expression="240" const="true" />
设置滑动距离
<Var name="move_dx" expression="(#touch_x-#touch_begin_x)" const="false" />
滑块x移动距离
<Var name="move_dy" expression="(#touch_y-#touch_begin_y)" const="false"/>
滑块y移动距离
<Var name="move_radius" expression="sqrt(#move_dx*#move_dx+#move_dy*#move_dy)" const="false" />
滑块移动距离
下面是滑动解锁代码,满足滑动距离条件解锁
<Unlocker name="unlocker" alwaysShow="true">
<StartPoint x="#touch_begin_x" y="#touch_begin_y" w="1" h="1"></StartPoint>
<EndPoint x="ifelse(ge(#move_radius,#unlock_dist),#touch_x,-1)" y="ifelse(ge(#move_radius,#unlock_dist),#touch_y,-1)" w="1" h="1"></EndPoint>
</Unlocker>
ps:滑动解锁关于tolerance建议最好添加下,否则会导致解锁困难,还有多个Unlocker 的时候alwaysShow="true"记得写下。by--千叶
主题锁屏滑动解锁代码整理
3
9
1
浏览593 发布于2019-12-17 12:54未知归属地
全部评论
最多点赞
最新发布
最早发布
写回答
所见即所得编辑器, editor1
工具栏
0/50000
新增插入模板功能
一键使用模板,快速填写内容,轻松发帖~
知道了
- 为了保障您的信息安全,请勿上传您的敏感个人信息(如您的密码等信息)和您的敏感资产信息(如关键源代码、签名私钥、调试安装包、业务日志等信息),且您需自行承担由此产生的信息泄露等安全风险。
- 如您发布的内容为转载内容,请注明内容来源。
我要发帖子
了解社区公约,与您携手共创和谐专业的开发者社区。






































苏公安网备 32011402010933号