I have a customised view CustomView
which I place inside the layout of my activity. Here is my layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/view1"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_alignParentTop="true"/>
<View
android:id="@+id/view2"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<com.musicmuni.riyaz.views.CustomView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="@id/view2"
android:layout_toEndOf="@id/view2"
android:layout_below="@id/view1"/>
</RelativeLayout>
Here, you see that my CustomView
is placed towards right of a View
with id view1
and below a View
with id view2
. What I do is set the width of CustomView
based on my need by overriding onMeasure
, so that I can scroll over my CustomView
. I still need the window size inside which my CustomView
has been placed. So lets say the screen dimension is 1200px X 800px
and the height of view1
is 150px
and the width of view2
is 60px
, then the window size of CustomView
should be 1050px X 740px
. How can I get this number? If I will use CustomView.getWidth()
, it will give me the width of the view that I had set inside onMeasure
. What is the way to get the correct window size?
Edit 1:
Here is a drawing of what I want to achieve. Hope this makes it more clear: