1

I am trying to have a RelativeLayout wrap it's content height and width. It seems to do fine on width, but the height does not wrap. It covers the entire screen. Anyone know why?

<?xml version="1.0" encoding="utf-8"?>



   <com.company.things.CameraControls
       xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/camera_control_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >


    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#60FFFFFF" >

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:onClick="clearDrawing"
            android:text="@string/clear" />

        <SeekBar
            android:id="@+id/sensitivity_seek"
            android:layout_width="250dp"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true" />

        <Switch
            android:id="@+id/live_switch"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignTop="@+id/sensitivity_seek"
            android:layout_toRightOf="@+id/sensitivity_seek"
            android:text="@string/live" />

    </RelativeLayout>

</com.company.things.CameraControls>
double-beep
  • 5,031
  • 17
  • 33
  • 41
steventnorris
  • 5,656
  • 23
  • 93
  • 174
  • May be because you put your UI elements on the bottom – Tim Nov 06 '14 at 16:17
  • @TimCastelijns That worked. And that's weird. I wanted to align the elements to the bottom of the relative layout and wrap_content. The button is larger than the other elements. I guess I can just align to the button. Make it an answer and I'll accept. – steventnorris Nov 06 '14 at 16:19

1 Answers1

1

It's because you put your UI elements on the bottom of the page.

Tim
  • 41,901
  • 18
  • 127
  • 145