I have a FrameLayout, containing various overlayed ImageViews:
<FrameLayout
android:id="@+id/australia_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/australia"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/map_australia"
/>
<ImageView
android:id="@+id/nsw"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/map_nsw"
android:visibility="invisible"
/>
<ImageView
android:id="@+id/victoria"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/map_victoria"
android:visibility="invisible"
/>
...etc...
</FrameLayout>
In my code I try and render my FrameLayout:
final Dialog dialog = new Dialog((Context) parent);
dialog.setContentView(R.layout.dialog_region);
FrameLayout fl = (FrameLayout) dialog.findViewById(R.id.australia_frame);
final int height = fl.getHeight();
Validate.isTrue(height > 0);
My code crashes with:
java.lang.IllegalArgumentException: The validated expression is false
at org.apache.commons.lang3.Validate.isTrue(Validate.java:180)
The line that's crashing is Validate.isTrue(height > 0);
.
Why does my FrameLayout not have a height? Is there a way to get the exact px height and width that my FrameLayout is rendering at?