android - 为什么 wrap_content 是填充高度?

标签 android android-layout android-xml android-wrap-content

我试图让 RelativeLayout 包装它的内容高度和宽度。它似乎在宽度上做得很好,但高度不环绕。它覆盖了整个屏幕。有人知道为什么吗?

<?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>

最佳答案

这是因为您将 UI 元素放在了页面底部。

关于android - 为什么 wrap_content 是填充高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26784129/

相关文章:

android - 带 null 参数的 addToBackStack 是什么意思?

android - 添加任何 .xml 文件时 Android Studio 2.0 中的 IDE fatal error

java - Dagger 注入(inject)的类在 Dagger 中保持为 null

android - Android 中 LaunchModes 的实际用例是什么?

android - measureSpec 返回错误值

android - 无法转换为维度 : type=0x1 when inflating the layout

android - 在 Android 中外包应用程序翻译的最佳做法是什么?

android - 触摸时可绘制的色调/暗淡

java - 带有 break 语句的无限 while 循环

android - 为什么我的 FloatingActionButton 图标是黑色的?