【发布时间】:2014-02-13 11:52:22
【问题描述】:
我正在为我正在学习的移动应用开发课程编写程序。该应用程序涉及我在屏幕上放置 2 个按钮。我知道当我输入 /2 时,它会将其放在中间,而当我输入 /3 时,它会将按钮放置在距离屏幕左侧三分之一处。因为我需要两个按钮,所以我想把左边的三分之一(我知道怎么做),右边的三分之一(我不知道怎么做)。我应该怎么做才能做到这一点?
我的代码 sn-p:
myRedButton.x = display.contentWidth /3
myRedButton.y = display.contentHeight -50
myGreenButton.x = display.contentWidth /2
myGreenButton.y = display.contentHeight -100
我是移动应用编程领域的新手,所以请保持简单。谢谢!
【问题讨论】:
-
谨慎选择布局并调整重力会有所帮助。
-
Idek “重力”指的是什么。我有很多东西要学
-
确保您在 XML 文件中使用的是 RelativeLayout 而不是 LinearLayout。
-
Please close your question by clicking the checkmark to the left of the answer that helped you most -
您是否使用 corona 进行编码?然后你可以这样做:
object.x = display.contentWidth-(display.contentWidth/3)。这会将对象放置到距屏幕右侧的间隙width/3的 x 位置。
标签: android mobile lua coronasdk