文档管理中心

多屏幕展示<MultiScreens>

功能概述

支持三屏幕内容切换,三屏划动切换控制动画。屏幕绘制可以通过Rectangle矩形图形和Image图片标签来实现。

应用场景

  • 用于滑动屏幕切换多壁纸锁屏。
  • 可用于游戏前面的介绍内容,每一屏展示一个说明步骤。
  • 可实现漫画壁纸,每个屏幕一个页面。

XML规范

收起
自动换行
深色代码主题
复制
  1. <Group x="">
  2. <!-- 第1屏-->
  3. <Group x="">
  4. <Rectangle x="" y="" w="" h="" fillColor="" />
  5. <!--<Image y="" alignV="" src="" />-->
  6. </Group>
  7. <!-- 第2屏-->
  8. <Group x="">
  9. <Rectangle x="" y="" w="" h="" fillColor="" />
  10. <!--<Image y="" alignV="" src="" />-->
  11. </Group>
  12. <!-- 第3屏-->
  13. <Group x="">
  14. <Rectangle x="" y="" w="" h="" fillColor="" />
  15. <!--<Image y="" alignV="" src="" />-->
  16. </Group>
  17. </Group>

参数说明

展开

参 数

类 型

选 项

注 释

Group

表达式

必填

元素组集合,当中的x属性为屏幕开始的x坐标位置

Rectangle

表达式

选填

矩形类型,可以用来绘制屏幕内容,相关的参数说明可以参照1.14几何图形

Image

表达式

选填

图片类型,可以用来绘制屏幕内容,相关的参数说明可以参照1.2图片

应用示例

示例一:演示用Rectangle矩形类型来绘制屏幕,fillColor填充颜色来区别三个不同的屏幕,dottedLine和cornerRadius可以指定虚线模式和矩形的圆角半径,具体的可以参照几何图形的参数说明。通过左右滑动可以实现三屏幕的切换的效果。

收起
自动换行
深色代码主题
复制
  1. <!-- 三屏划动切换控制动画 -->
  2. <Var name="move_go">
  3. <VariableAnimation initPause="true" loop="false">
  4. <AniFrame value="#move1" time="0" varSpeedFlag="QuartFun_Out" />
  5. <AniFrame value="#move2" time="200" />
  6. </VariableAnimation>
  7. </Var>
  8. <Var name="base" expression="0"/>
  9. <Var name="move" expression="#touch_x-#touch_begin_x"/>
  10. <Var name="temp" expression="#base+#move"/>
  11. <Var name="maxvalue" expression="500*#screen_width/1080"/>
  12. <Var name="value" expression="ifelse(lt(#temp,-#maxvalue),-#maxvalue,gt(#temp,#maxvalue),#maxvalue,#temp)"/>
  13. <Var name="scalevalue" expression="#value/#maxvalue"/>
  14. <ExternalCommands>
  15. <Trigger action="resume">
  16. <Command target="a.visibility" value="true"/>
  17. </Trigger>
  18. <Trigger action="pause">
  19. <Command target="a.visibility" value="false"/>
  20. </Trigger>
  21. </ExternalCommands>
  22. <!-- 此按钮用来判断是向左还是向右滑动 -->
  23. <Button x="0" y="120" w="1080" h="#screen_height">
  24. <Trigger action="down">
  25. <VariableCommand name="move1" expression="#move2+#touch_x-#touch_begin_x" />
  26. <VariableCommand name="move2" expression="max(min(#move2+#zf_end*1080,1080),-1080)" />
  27. <Command target="move_go.animation" value="play" />
  28. </Trigger>
  29. <Trigger action="up">
  30. <VariableCommand name="base" expression="#value"/>
  31. <VariableCommand name="move" expression="0"/>
  32. </Trigger>
  33. </Button>
  34. <Group name="a" x="#scalevalue*ifelse(lt(#scalevalue,0),1080,1080)" >
  35. <!-- 第1屏-->
  36. <Group x="-1080" >
  37. <Rectangle x="0" y="0" w="1080" h="1920" fillColor="#b6937c" dottedLine="20,10,10,20" cornerRadius="55,55"/>
  38. </Group>
  39. <!-- 第2屏-->
  40. <Group x="0" >
  41. <Rectangle x="0" y="0" w="1080" h="1920" fillColor="#ae6b5a" dottedLine="20,10,10,20" cornerRadius="55,55"/>
  42. </Group>
  43. <!-- 第3屏-->
  44. <Group x="1080" >
  45. <Rectangle x="0" y="0" w="1080" h="1920" fillColor="#59493f" dottedLine="20,10,10,20" cornerRadius="55,55"/>
  46. </Group>
  47. </Group>

示例二:演示用三个不同的Image来做屏幕,通过左右滑动实现三屏幕切换的效果。

收起
自动换行
深色代码主题
复制
  1. <!-- 三屏划动切换控制动画 -->
  2. <Var name="move_go">
  3. <VariableAnimation initPause="true" loop="false">
  4. <AniFrame value="#move1" time="0" varSpeedFlag="QuartFun_Out" />
  5. <AniFrame value="#move2" time="200" />
  6. </VariableAnimation>
  7. </Var>
  8. <Var name="base" expression="0"/>
  9. <Var name="move" expression="#touch_x-#touch_begin_x"/>
  10. <Var name="temp" expression="#base+#move"/>
  11. <Var name="maxvalue" expression="500*#screen_width/1080"/>
  12. <Var name="value" expression="ifelse(lt(#temp,-#maxvalue),-#maxvalue,gt(#temp,#maxvalue),#maxvalue,#temp)"/>
  13. <Var name="scalevalue" expression="#value/#maxvalue"/>
  14. <ExternalCommands>
  15. <Trigger action="resume">
  16. <Command target="a.visibility" value="true"/>
  17. </Trigger>
  18. <Trigger action="pause">
  19. <Command target="a.visibility" value="false"/>
  20. </Trigger>
  21. </ExternalCommands>
  22. <!-- 此按钮用来判断是向左还是向右滑动 -->
  23. <Button x="0" y="120" w="1080" h="#screen_height">
  24. <Trigger action="down">
  25. <VariableCommand name="move1" expression="#move2+#touch_x-#touch_begin_x" />
  26. <VariableCommand name="move2" expression="max(min(#move2+#zf_end*1080,1080),-1080)" />
  27. <Command target="move_go.animation" value="play" />
  28. </Trigger>
  29. <Trigger action="up">
  30. <VariableCommand name="base" expression="#value"/>
  31. <VariableCommand name="move" expression="0"/>
  32. </Trigger>
  33. </Button>
  34. <Group name="a" x="#scalevalue*ifelse(lt(#scalevalue,0),1080,1080)" >
  35. <!-- 第1屏-->
  36. <Group x="-1080">
  37. <Image y="#screen_height" alignV="bottom" src="screen1.png" />
  38. </Group>
  39. <!-- 第2屏-->
  40. <Group x="0">
  41. <Image y="#screen_height" alignV="bottom" src="screen2.jpg"/>
  42. </Group>
  43. <!-- 第3屏-->
  44. <Group x="1080">
  45. <Image y="#screen_height" alignV="bottom" src="screen3.jpg"/>
  46. </Group>
  47. </Group>