This component is used to specify a display area on the lock screen. In the display area, a series of operations and commands such as those defined in <Trigger> can be triggered. You can use multiple status tags to display different images or texts in different status.
<Button name="" x="" y="" w="" h="" visibility="" longTouchTime="" interceptButtonTouch="">
<Trigger action="" target="" property="" value="">
<Command target="" value=""/>
</Trigger>
<Trigger action="" target="" property="" value=""/>
<Normal>
<Image/>
</Normal>
<Pressed>
<Image/>
<Text/>
</Pressed>
</Button> Parameter | Type | Mandatory | Description |
|---|---|---|---|
name | String | No | Button name. |
visibility | String | No | Element visibility. Expressions are supported. If this parameter is set to 0 or a negative value, the element is invisible. If this parameter is set to a positive value, the element is visible. |
longTouchTime | Number | No | Long press duration to trigger the command defined in Trigger action="long", in milliseconds. The default value is 1000ms. |
interceptButtonTouch | String | No | Indicates whether a button has been triggered. If interceptButtonTouch is set to true, the button can be triggered only once. |
Trigger | String | Yes | Command trigger. When a button action is performed, a series of commands is triggered to control the attribute of an element. This tag is applicable not only to the button, but also the unlock control and slider. |
Normal | String | No | Elements displayed when a button is in normal state. You can specify the elements by adding <Image>, <Text>, <SourceImage>, <Time>, <DateTime>, <ImageNumber>, and <Group>. |
Pressed | String | No | Elements to be displayed when a button is pressed down. The elements supported by this parameter are the same as those supported by Normal. The difference is that elements are inactive and invisible when the button is in normal state. When the button is pressed down, the elements become active and visible. |
Parameters in Trigger
Parameter | Type | Mandatory | Description |
|---|---|---|---|
action | String | Yes | Button action. The options are down (press down), up (release), double (double-click), resume (turn on the screen), pause (turn off the screen), long (long press), and click (tap). |
target | String | Yes | Target name. |
property | String | No | Attribute name. Currently, only the visibility attribute can be controlled. Other attributes will be extended in the future. |
value | String | No | Attribute value. The options are true, false, and toggle. |
Example 1: When a button is in normal state, display the text "normal" in white and a small sun image. When the button is pressed down, display the text "pressed" in white and a red heart image. When the button is released, the elements are restored to those in the normal state.
<Button name="zk1" x="300" y="300" w="470" h="300">
<Pressed>
<Image x="300" y="300" src="ax.png"/>
<Text x="300" y="280" text="press" visibility="1"/>
</Pressed>
<Normal>
<Image x="300" y="300" src="ty.png"/>
<Text x="300" y="280" text="normal" visibility="1"/>
</Normal>
</Button> Example 2: Before a button is tapped, make the button visible and display "Visibility: The visibility attribute is false and the button is visible" in the text box. After the button is tapped, make the button invisible and display "Visibility: The visibility attribute is true and the button is invisible" in the text box.
<!-- Visibility-->
<Image x="22" y="1030" w="180" h="180" src="7.png" visibility="eq(#kj,0)"/>
<Text x="250" y="1090" align="left" alignV="top" color="#ffffff" size="45" text="Visibility: The visibility attribute is true and the button is invisible" visibility="eq(#kj,1)"/>
<Text x="250" y="1090" align="left" alignV="top" color="#ffffff" size="45" text="Visibility: The visibility attribute is false and the button is visible" visibility="eq(#kj,0)"/>
<Button x="22" y="1030" w="180" h="180">
<Trigger action="down">
<VariableCommand name="kj" expression="#kj+1" condition="le(#kj,2)" persist="true"/>
<VariableCommand name="kj" expression="0" condition="eq(#kj,2)" persist="true"/>
</Trigger>
</Button>