- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个 DialogFragment
。
布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:maxHeight="280dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/line/>
<View
android:id="@+id/line"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="@color/black"/>
</android.support.constraint.ConstraintLayout>
我想最初“包装回收站 View 内容”(高度),但它不能超过 280dp。似乎 android:maxHeight
没有任何效果。
最佳答案
只要您的父布局是 ConstraintLayout
,您就可以仅使用 XML 来实现这一点,而您的父布局似乎是。对您的 RecyclerView
标记进行以下更改:
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintHeight_default="wrap"
app:layout_constraintHeight_max="280dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/line/>
关键属性是这三个:
android:layout_height="0dp"
app:layout_constraintHeight_default="wrap"
app:layout_constraintHeight_max="280dp"
通常,当您约束 View 的两侧时,您只使用 0dp
维度,但实际上您所要做的就是提供足够的约束来定义 View 大小(并且限制双方只是做到这一点的最简单方法)。将高度设置为“匹配约束”后,您可以将默认高度约束与最大高度约束结合起来,以准确获得您要查找的内容。
请注意,您必须为此使用 1.1 版的约束布局库。确保您应用的 build.gradle 文件包含如下内容:
implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta5'
关于android - maxHeight 不适用于 RecyclerView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49449828/
这个问题在这里已经有了答案: How to get an HTML element's style values in JavaScript? (5 个答案) 关闭 5 年前。
我创建了一个小项目,在其中必须显示一个模式对话框,我使用了 jquery-ui 对话框。 我想以百分比定义对话框的最大高度。我尝试了几种方法,但都不起作用。 请有人帮我解决可能出现的问题。 参见htt
我在设置以下 xaml 布局时遇到问题: RowHeightAuto.xaml DataGrid1 控件没有显示任何定
我有一个 minHeight 为 50 和 maxHeight 为 400 的 ConstrainedBox。CB 包含一个将自身着色为黄色的 Container。 请注意,这里的 CB 是一种抽象。
我在仅使用可用视口(viewport)设置颜色框时遇到问题。一旦我设置了 maxHeight 或 maxWidth 属性,就不会显示任何图像。颜色框打开,但停留在“旋转轮”处。 function sh
我正在使用 Colorbox 在我的网站上显示高清图片。有些照片是肖像,有些是风景。我将 colorbox 设置为具有 maxHeight 和 maxWidth,它适用于横向图片。 问题是人像图片显示
我的目标是使用 .pane-documentation-tree-menu 类调整 div 的大小。我已经实现了这一点,但只有固定高度,如果我尝试添加 maxHeight 它不起作用。 代码如下:
我有一个 DialogFragment。 布局: 我想最初“包装回收站 View 内容”(高度),但它不能超过 280dp。似乎 android:maxHeight 没有任何
函数: MAX-HEIGHT(node) if(node == NIL) return -1; else return max(MAX-HEIGHT(node.leftC
这是我的布局。 我在线性布局上设置了最大和最小高度,但最大高度似乎不起作用。事实上,如果 TextView R.id.testo 有很多文本,这将不会被修剪。如果我设置固定高度,则不会发生这种情况。但
我不想限制行数,我想限制 TextInputLayout 的最大高度,这样如果太长就会垂直滚动。 我对代码解决方案没意见。 目前 maxHeight 属性对 TextInputLayout 或 Edi
我正在尝试获取constrains.maxHeight。 这是我使用的代码: LayoutBuilder( builder: (BuildContext context, B
我试图为 div 的高度设置动画,因此它会扩展到自动高度 - 我知道这是不可能的,这就是我尝试使用 maxHeight 的原因。这虽然有很多错误。任何想法为什么?包含代码片段和 jsFiddle。 抱
jQuery $(function maxHeight() { var maxH = 0; var contentH = 'calc(100vh - 79px)'; $(".left, .
我是 Android 编程的新手,我被困在一个简单的问题上。 我有一个带有一些按钮和 Logo 的基本主页。我使用 LinearLayout 和 layout_weight 属性来分配所有组件。 这是
我有以下“按钮栏”布局设置: 我希望按钮栏(RelativeLayout)高度为屏幕高度的 10%,所以我使用了 layout_weigh
我需要设置 TextView 的最大高度(使用 maxHeight 或 maxLines)。如果有更多的文本行,则应显示滚动条。我应该为此使用什么标记? 最初的想法是用ScrollView包裹Text
View's have a minHeight但不知何故缺少 maxHeight: 我想要实现的是让一些项目( View )填充 ScrollView。当有 1..3 个项目时,我想直接显示它们。这意
我更新了我的 tcpdf 库,我现在面临这种奇怪的行为,显然 maxheight 参数覆盖了 minimum height 参数,即使单元格内容不是那个高。 来自docs它说: $h: (float)
ScrollView文档提及: Keep in mind that ScrollViews must have a bounded height in order to work, since the
我是一名优秀的程序员,十分优秀!