minHeight 不适用于 Linearlayout 中的 Weight=“1”

2024-04-17

我想要一个视图,如果屏幕尺寸较小,则可以具有最小高度或wrap_content;如果屏幕尺寸较大,则占据其余空间。该视图是其父视图的中间子视图。

目前,我正在使用 LinearLayout 的权重。它在大屏幕上工作正常,但在小屏幕上它不显示视图。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/main_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/speaker_detail_background"
    android:clickable="true"
    android:paddingLeft="@dimen/padding_7dp"
    android:paddingRight="@dimen/padding_7dp"
    android:orientation="vertical"
    >
    <ImageView
        android:id="@+id/down_arrow_image_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"
        android:padding="@dimen/padding_15dp"
        android:src="@drawable/down_arrow_icon" />


    <RelativeLayout
        android:id="@+id/lytSpeakerDetails"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/down_arrow_image_view"
        android:minHeight="200dp"
        android:layout_weight="1"
        >
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true">
            <RelativeLayout
                android:id="@+id/title_bar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:theme="@style/ThemeOverlay.AppCompat.Dark"
                android:visibility="visible"
                >

                <com.harman.jblconnectplus.ui.customviews.CustomFontTextView
                    android:id="@+id/speaker_name_title_textview"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:background="@android:color/transparent"
                    android:drawableLeft="@drawable/edit_name"
                    android:drawablePadding="@dimen/padding_5dp"
                    android:ellipsize="end"
                    android:maxLength="16"
                    android:text="@string/speaker_name"
                    android:textColor="@android:color/white"
                    android:textSize="@dimen/textSize_18sp"
                    app:font="@string/font_name_opensans_semi"
                    />

                <com.harman.jblconnectplus.ui.customviews.CustomFontTextView
                    android:id="@+id/setting_text_view"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/speaker_name_title_textview"
                    android:layout_centerHorizontal="true"
                    android:text="@string/setting"
                    android:visibility="invisible"
                    android:textColor="@color/white"
                    android:textSize="14sp"
                    app:font="@string/font_name_opensans_semi"
                    />
            </RelativeLayout>
            <LinearLayout
                android:id="@+id/lytSeekBar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_below="@id/title_bar"
                android:layout_marginLeft="@dimen/brightness_margin"
                android:layout_marginRight="@dimen/brightness_margin"
                android:visibility="visible">
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/darker"
                    android:layout_gravity="center_vertical"
                    />
                <SeekBar
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:id="@+id/seekBar"
                    android:thumb="@drawable/knob"
                    android:progressDrawable="@drawable/seekbar_progressbar"
                    android:indeterminate="false"
                    android:splitTrack="false"
                    android:maxHeight="3dp"
                    android:paddingLeft="10dp"
                    android:paddingRight="10dp"
                    android:progress="0"
                    android:secondaryProgress="0"
                    android:max="255"

                    />
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/brighter"
                    android:layout_gravity="center_vertical"/>
            </LinearLayout>
        </RelativeLayout>
    </RelativeLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:id="@+id/bottom_details_layout"
        android:layout_height="wrap_content"
        android:background="@drawable/round_border_white_bg"
        android:orientation="vertical"
        android:layout_marginTop="@dimen/margin_20dp"
         >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="@dimen/padding_5dp"
            android:gravity="bottom">

            <include layout="@layout/speaker_detail_firmware_layout" />
        </LinearLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="0.5dp"
            android:background="@color/divider_view" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <include layout="@layout/speaker_detail_voice_layout" />
        </LinearLayout>
    </LinearLayout>


</LinearLayout>

请建议。


Your View正在受到约束。minHeight如果View受到限制。请参阅文档 https://developer.android.com/reference/android/view/View.html#attr_android:minHeight.

机器人:最小高度

定义视图的最小高度。不保证视图能够达到此最小高度(例如,如果其父布局用较小的可用高度限制它)。

Maybe a ScrollView是您可以使用的东西,因为它为您提供了几乎无限的空间。问题是,当空间成为问题并且一切都无法容纳时,您希望发生什么。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

minHeight 不适用于 Linearlayout 中的 Weight=“1” 的相关文章

随机推荐

  • 如何停止java执行器类中的所有可运行线程?

    final ExecutorService executor Executors newFixedThreadPool 1 final Future
  • C++ 无法将指针对中的指针初始化为 NULL

    我正在使用 g 4 4 7 进行编译 目前不能再更高 并使用 std gnu 0x编译器开关 它应该允许第三行的语法 typedef std vector
  • & 的用途是什么

    以下 URL 的行为有什么不同吗 我不知道为什么 amp 插入了 有什么区别吗 www testurl com test param1 test amp current true versus www testurl com test pa
  • 使用 jQuery 在单击另一个音频文件时停止/暂停音频

    我创建了一个网站 其中包含我拍摄的人物的图像缩略图 当访问者单击其中一个缩略图时 将使用 jQuery 显示完整图像 并播放音频介绍 我对每个缩略图 图像组合都有不同的音频介绍 目前有 15 个 每天都会添加更多 我想确保 如果访问者在上一
  • 如何在Python中初始化嵌套字典

    我正在使用 Python v2 7 字典 将一个字典嵌套在另一个字典中 如下所示 def example format str year value format to year to value dict In the actual co
  • .NET 4:托管代码本身会导致堆损坏吗?

    我的多线程托管程序中出现堆损坏 进行一些测试后 我发现仅当后台线程在程序中处于活动状态 它们是可切换的 时才会发生损坏 这些线程使用一些第三方组件 在检查了线程和第 3 方组件的代码 使用 NET Reflector 后 我发现它们都是托管
  • 我的答案是用相同的代码改变的[重复]

    这个问题在这里已经有答案了 我是一个完全的Python初学者 我正在尝试解决这个问题 如果一个数是前 n 个正数之和 则该数称为三角数 某些 n 的整数 例如 10 是三角形 因为 10 1 2 3 4 21 是三角形 因为 21 1 2
  • C# WPF OpenFileDialog 在 XP 中导致崩溃,但在 Vista 中则不然

    我有一个 WPF 应用程序 可以在我的 Vista 开发计算机上正常运行 但不能在生产 XP 机器上运行 唯一的问题是调用 OpenFileDialog Show 一旦我调用该方法 应用程序就会在 XP 盒子上终止 该问题不会触发异常 我已
  • Linq 中按子集合中的最小值对父集合进行排序

    Parent List
  • 如何平滑分段的斑点?

    我收到一些闪烁 锐线 以及分段斑点 如何减少它们以使边界更平滑 为了更清楚起见 我附上了带有输入和预期输出的图像 请注意 它是二进制图像 我没有原始图像 灰色 输入是二进制的 我尝试过高斯模糊 但该方法使我的形状变小 mask ndimag
  • 无法通过模块查看或修改 PYTHONHASHSEED 的值

    试图看到的价值PYTHONHASHSEED https docs python org 3 4 using cmdline html highlight pythonhashseed envvar PYTHONHASHSEED通过使用 th
  • Angular2 和禁用按钮异常

    在我的代码中 我有一个按钮 只要表单无效或不脏 该按钮就会被禁用 I have
  • 如何在VB.net中使用字典?

    我编写了这个函数来自动将字符串数组中的不同值的性别更正为 M 或 F 它工作得很好 但我的经理告诉我使用字典 他说这更有效 但我不知道 有人愿意帮助我了解如何做到这一点吗 谢谢 Public Function AutoGender ByVa
  • 获取任何枚举值的扩展方法

    我一直在尝试创建一个适用于任何枚举的扩展方法 以返回其值 而不是这样做 Enum GetValues typeof BiasCode Cast
  • 与查找数据集连接后进行多列值查找

    我正在使用spark sql 2 4 1v如何根据列的值进行各种连接 我需要获得多个查找值map val给定值列的列 如下所示 样本数据 val data List 20 score school 2018 03 31 14 12 21 s
  • Google Tasks API:403 禁止,超出服务限制

    您好 Google Tasks API 团队 从几天前开始 我们就开始 403 Forbidden 对于我们的许多用户来说 您能检查一下发生了什么事吗 我们的 API 控制台很干净 calls 远低于配额 Caused by com goo
  • 分析 Windbg 中的故障转储

    我正在使用第三方闭源 API 它会抛出一个异常 指出 所有命名管道都忙 我想进一步调试 而不是单步调试 这样我就可以真正了解幕后发生的事情 我使用 WinDbg 转储了这个过程 我现在应该使用什么命令来分析此转储 Thanks 您可以开始执
  • 在联合查询中使用 Wikidata 标签服务

    我想知道是否可以在联合查询中使用维基数据标签服务 例如 以下查询 Query from a local SPARQL enpoint select item itemLabel where SERVICE
  • 如何计算 RectTransform 中的 sizeDelta?

    我编写了自定义布局所需的自定义内容适配程序 所以 我需要控制RectTransform sizeDelta当锚点不同时属性 但我无法显示该值 我不需要Unity3D API参考资料 我读了它 但什么也没得到 因为它只说 此 RectTran
  • minHeight 不适用于 Linearlayout 中的 Weight=“1”

    我想要一个视图 如果屏幕尺寸较小 则可以具有最小高度或wrap content 如果屏幕尺寸较大 则占据其余空间 该视图是其父视图的中间子视图 目前 我正在使用 LinearLayout 的权重 它在大屏幕上工作正常 但在小屏幕上它不显示视