I have a floor plan which is centred in an ImageView. The aspect ratio of the image is preserved so there is some space on either side of the image (indicated in red colour).
How can I determine the width of this red space in pixels or dp?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MyActivity"
android:background="@color/red"
android:orientation="vertical">
<ImageView
android:id="@+id/floor_plan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/floor_plan2"
android:adjustViewBounds="true"
android:layout_toStartOf="@+id/locateMe"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
/>
I note that the margins have been set to 0dp in the dimens.xml file.