给定一个简单的RelativeLayout,如下所示:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#0fffff">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="@drawable/img001" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
布局边框和图像边框之间的左/上间距取决于在 imageView 中加载的图像的宽/高比。

在此布局中显示图像后,我如何(以编程方式)知道实际边距(青色区域的宽度和高度)?