Android Rect 对象中的顶部、左侧、右侧和底部是什么意思
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22589322/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does top, left, right and bottom mean in Android Rect object
提问by Hunsu
I have an Android project where I should make Apples fall. The apples are painted in a Rect. So I created a function that change the Rect position and repaint. Here's my function :
我有一个 Android 项目,我应该让苹果掉下来。苹果被画在一个矩形中。所以我创建了一个改变 Rect 位置并重新绘制的函数。这是我的功能:
private void updateApplesPosition() {
for(Rect rect:fallingDownFruitsList)
rect.set(rect.left, rect.top +10, rect.right, rect.bottom +10);
}
I have a problem : the Apples don't fall but go from right to left. To make the apples fall I changed the code by this :
我有一个问题:苹果不会掉下来,而是从右到左。为了让苹果掉下来,我通过以下方式更改了代码:
private void updateApplesPosition() {
for(Rect rect:fallingDownFruitsList)
rect.set(rect.left+10, rect.top, rect.right+10, rect.bottom);
}
回答by LOG_TAG
This image will explain you in detail:
此图将为您详细解释:
leftThe X coordinate of the left side of the rectangle
topThe Y coordinate of the top of the rectangle
rightThe X coordinate of the right side of the rectangle
bottomThe Y coordinate of the bottom of the rectangle
left矩形左侧的 X 坐标
top矩形顶部的 Y 坐标
right矩形右侧的 X 坐标
bottom矩形底部的 Y 坐标
回答by adneal
Parameters
参数
leftThe X coordinate of the left side of the rectangle
topThe Y coordinate of the top of the rectangle
rightThe X coordinate of the right side of the rectangle
bottomThe Y coordinate of the bottom of the rectangle
left矩形左侧的 X 坐标
top矩形顶部的 Y 坐标
right矩形右侧的 X 坐标
bottom矩形底部的 Y 坐标