androidandroid-layoutandroid-xmlandroid-wrap-content

Why does wrap_content is filling height?


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>

Solution

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