现在我正在创建一个应用程序。这里我们有帮助部分。通常,像 Youtube、NetFlix 和 Vimeo 这样的巨型应用程序不会在他们的应用程序中显示他们的帮助部分。但在我们的案例中,我们想显示帮助部分。所以会有一些问题。但从设计上看,它就像手风琴效果一样。
我知道这很难做到。我不知道,如果我使用简单的标签,如何获得焦点。
我尝试了一些不同的方法。
方法一:Label
一一使用。所以我可以通过使用属性来隐藏和显示。visible
疑问:那我怎样才能得到焦点呢?所以如果有20个问题,我该如何设置焦点?
方法二:使用LabelList
. 所以它有自动对焦。
疑问:那么如何使用 LabelGroup隐藏和显示内容?我认为,没有可见的财产。
最后,我使用了动画。
为此,我使用了 Vector2DFieldInterpolator Animation
这是我的代码。
<component name = "AnimationV2DExample" extends = "Group" >
<children>
<Rectangle
width = "900"
height = "330"
color = "0x10101000" >
<Label
id="QuestionLabel"
text="What is this?"/>
<Rectangle
id="answer1rect"
width = "900"
height = "330"
color = "0x10101000" >
<Label
id="AnswerLabel"
text="This is a Roku App."
visible="false"/>
</Rectangle>
<Label
id="QuestionLabel1"
text="What is that?"/>
<Rectangle
id="answer2rect"
visible = "false"
color = "0x10101000" >
<Label
id="AnswerLabel"
text="This is a Roku App."
visible="false"/>
</Rectangle>
<Animation
id = "exampleVector2DAnimationrev"
duration = "7"
easeFunction = "outExpo" >
<Vector2DFieldInterpolator
id = "exampleVector2D"
key = "[ 1, 0 ]"
keyValue = "[ [0.0,50.0], [0.0,0.0] ]"
fieldToInterp = "AnswerLabel.translation" />
</Animation>
</Rectangle>
</children>
</component>
这是 Brightscript
sub init()
examplerect = m.top.boundingRect()
centerx = (1280 - examplerect.width) / 2
centery = (720 - examplerect.height) / 2
m.top.translation = [ centerx, centery ]
m.revanimation = m.top.findNode("exampleVector2DAnimationrev")
m.answer = m.top.findNode("AnswerLabel")
m.answerRec = m.top.findNode("answer1rect")
m.qustion1 = m.top.findNode("QuestionLabel1")
m.qustion1.translation = [40,100]
m.answer.translation = [50,50]
m.question = m.top.findNode("QuestionLabel")
end sub
function onKeyEvent(key as String, press as Boolean) as Boolean
handled = false
if press then
if(key = "OK" AND m.question.id = "QuestionLabel")
m.answer.visible = true
m.revanimation.repeat = false
m.revanimation.control = "start"
handled = true
end if
end if
return handled
end function
那么我怎样才能用它来制作一个成功的手风琴呢?我走对了吗?或者如果不可能,请建议我更好的方法。