理解Android中的Rect

理解Android中的Rect,android,Android,我试图研究Android中的坐标系 我想知道为什么右边的X坐标值中会出现负号 矩形的总宽度应为100px。(请参见id为“image”的图像) 矩形的结果是: Rect(20, 95 - 120, 195) 我的xml布局文件: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_

我试图研究Android中的坐标系

我想知道为什么右边的X坐标值中会出现负号

矩形的总宽度应为100px。(请参见id为“image”的图像)

矩形的结果是:

Rect(20, 95 - 120, 195)
我的xml布局文件

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_marginLeft="10px"
    android:layout_marginTop="10px"
    android:layout_height="match_parent">

<LinearLayout
    android:orientation="vertical"
    android:layout_marginLeft="10px"
      android:layout_marginTop="10px"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">


     <ImageView 
         android:id="@+id/image"
         android:src="@drawable/ic_launcher"
         android:layout_width="100px"
         android:layout_height="100px"
         />

     </LinearLayout>
     <ImageView 
         android:id="@+id/image2"
         android:src="@drawable/ic_launcher"
         android:layout_width="100px"
         android:layout_height="100px"
         />

</LinearLayout>


我找到了答案。它实际上是(x1,y1),(x2,y2)。连字符符号只是一个分隔符。

显示一些代码,您如何获得这个
Rect
值?连字符不是分隔符,它是一个减法,因此是一个语法错误,因为构造函数不带3个参数。我对imageview使用了“getglobalvisiblerect()”方法,并传递了一个Rect变量。带有连字符的输出是我在结果中得到的rect的输出。