This is my xml:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent"
>
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/header"
android:background="@android:color/white"
>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/btnBack"
android:text="Back"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
/>
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/icon"
android:layout_centerInParent="true"
/>
</RelativeLayout>
<RelativeLayout
android:layout_below="@+id/@+id/header"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="@+id/view"
android:layout_above="@+id/footer"
>
</RelativeLayout>
<RelativeLayout
android:id="@+id/footer"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:background="@android:color/white"
>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/btn1"
android:text="btn1"
android:layout_alignParentLeft="true"
/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/btn2"
android:text="btn2"
android:layout_centerHorizontal="true"
/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/btn3"
android:text="btn3"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
the relative layout view is in between the two layouts.
I want to get the size of this relative layout(i.e height and width) in my code.I tried it by using getWidth and getHeight but it is showing 0.
Is there any other way?
1 Answer