Android Rect对象中顶部,左侧,右侧和底部的含义是什么 [英] What does top, left, right and bottom mean in Android Rect object

查看:157
本文介绍了Android Rect对象中顶部,左侧,右侧和底部的含义是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android项目,应该让苹果跌倒。苹果涂在矩形中。因此,我创建了一个更改Rect位置并重新绘制的函数。这是我的功能:

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 :

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);
}


推荐答案

该图片将详细解释您:


矩形左侧的X坐标

top 矩形顶部的Y坐标

矩形右侧的X坐标

底部矩形底部的Y坐标

这篇关于Android Rect对象中顶部,左侧,右侧和底部的含义是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆