我正在开发UI,在该UI中,我需要实现在任何智能手机中拖动状态栏的类似效果。
这会在单击时将元素向下滑动(这意味着其高度会增加)
我尝试使用以下代码来获取元素的“ NO x,y values change”
MouseArea{
id : zone2MouseArea
anchors.fill : parent
drag.target: zone2ID
drag.axis: Drag.YAxis
drag.minimumY: 0
drag.maximumY: 0.1
}
和onYChanged()我增加了高度。
但是,这不足以满足我的要求。我需要滑动元素以更改其高度视图,而无需更改其x,y值
我已经做了一个基本的例子。希望能帮助到你。到目前为止,我还没有IDE,因此请检查语法错误
import QtQuick 1.1
Rectangle
{
width: 560
height: 560
color: "blue"
Rectangle
{
id: slider
width: parent.width
height: parent.height
y: - parent.height * .90
color: "yellow"
property bool isAtTop: true
Behavior on y { NumberAnimation { duration: 300 } }
Text
{
text: qsTr("12:34 PM")
anchors.bottom: parent.bottom
color: "black"
}
Text
{
text: qsTr("Battery | Wifi | Updates")
anchors.centerIn: parent
color: "black"
font.pixelSize: 25
}
MouseArea
{
id: draggingMouse
anchors.fill : parent
drag.target: parent
drag.axis: Drag.YAxis
drag.minimumY: - parent.height * .90
drag.maximumY: 0
onReleased:
{
if ( true == slider.isAtTop )
{
if( slider.y < - parent.height * .80 )
slider.y = - parent.height * .90
else
{
slider.y = 0
slider.isAtTop = false
}
}
else
{
if( slider.y < - parent.height * .20 )
{
slider.y = - parent.height * .90
slider.isAtTop = true
}
else
{
slider.y = 0
}
}
}
}
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句