0

I have a RelativeLayout with several other children (other Layouts, imageviews and buttons).

All of the interior layouts/views adapt to the RelativeLayout in question. Can I make this RelativeLayout fill the screen exactly?

EDIT: My layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:id="@+id/container"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:gravity="center_vertical|center_horizontal"
   android:layout_gravity="center_vertical" >

 <ScrollView
      android:layout_width="match_parent"
      android:layout_height="match_parent" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center_vertical"
    android:gravity="center_vertical"
    android:orientation="vertical" >

 <RelativeLayout
    android:id="@+id/start_activity_relLayout_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/start_activity_relLayout_container_bottom"
    android:gravity="center_horizontal"
    android:layout_gravity="center_vertical" >

 <RelativeLayout
    android:id="@+id/relLayout_dialogfragment_image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/linLayout_imageview_container"
    android:gravity="center_vertical" >

    <ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/tutorial_thirdview"
        android:text="@string/button_servicerequirement" />

</RelativeLayout>
 </RelativeLayout>

  <RelativeLayout
    android:id="@+id/start_activity_relLayout_container_bottom"
    android:layout_width="match_parent"
    android:layout_height="30dp"
    android:layout_marginTop="@dimen/two">

  <LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true">

     <Button
        android:id="@+id/image_cancel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_cancel"
        style="@style/button_standard_bright_smaller" 
        android:layout_marginRight="3dp"/>
     <Button
        android:id="@+id/image_ok"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_ok" 
        android:layout_marginLeft="3dp"/>
       </LinearLayout>
   </RelativeLayout>
  </LinearLayout>  
 </ScrollView>  
</RelativeLayout>

EDIT 2: I am setting the imageview dynamically btw.

deimos1988
  • 5,896
  • 7
  • 41
  • 57

1 Answers1

0

Have you tried setting RelativeLayout's layoutWidth and layoutHeight properties to match_parent in your xml layout file?

Leandros
  • 16,805
  • 9
  • 69
  • 108
Mr.Radar
  • 775
  • 1
  • 11
  • 32
  • Yes, unfortunately that didn't help. I also have a ScrollView as the next child in the RelativeLayout - might that be the problem? – deimos1988 May 14 '14 at 13:31
  • could you post your xml layout? – Mr.Radar May 14 '14 at 13:33
  • `fill_parent` is deprecated since API Level 8. Use `match_parent`. Ignoring that, the answer should be correct. – Leandros May 14 '14 at 13:39
  • @Leandros Unfortunately, the layout fills more than the screen. That is why I have a ScrollView inside, but I would like to not need the ScrollView. – deimos1988 May 14 '14 at 13:45
  • Have a look at http://stackoverflow.com/questions/7134085 The layout presented there uses a ScrollView with android:fillViewport=true as root layout. – Mr.Radar May 14 '14 at 13:47