This view is not constrained vertically: at runtime it will jump to the top unless you add a vertical constraint

时间: 2024-04-05 09:32:55 浏览: 25
这个问题是关于Android布局的。意思是说一个view在竖直方向上没有被限制,因此在运行时它会跳到顶部,除非你添加一个竖直方向上的限制。解决方法是在xml文件中为该view添加一个竖直方向上的约束条件,例如使用layout_constraintTop_toBottomOf或者layout_constraintBottom_toTopOf。这样就可以避免在运行时出现布局问题了。
相关问题

<ImageView android:id="@+id/ic_meter_indicator_car_speed_unit" android:layout_width="74px" android:layout_height="35px" android:layout_marginLeft="8dp" app:layout_constraintLeft_toRightOf="@+id/tv_meter_car_speed" app:srcCompat="@drawable/ic_car_speed_unit" tools:layout_editor_absoluteY="184dp" />我这样子写有什么问题吗,为什么会报错This view is not constrained vertically: at runtime it will jump to the top unless you add a vertical constraint

这个错误提示是因为你在布局文件中定义的视图没有垂直约束。在使用 ConstraintLayout 的时候,每个视图都必须有水平和垂直方向的约束,否则会导致布局错误。在你的布局文件中,你需要为该视图添加一个垂直方向的约束,例如: ``` app:layout_constraintTop_toBottomOf="@+id/上一个视图的ID" ``` 这个约束将使视图与其他视图垂直对齐。你可以根据你的具体布局需求来为该视图添加垂直方向的约束。

This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime unless you add the constraints解决方法

这个错误通常是由于你在布局文件中使用了没有约束的视图所引起的。 要解决这个问题,你需要在布局文件中添加适当的约束条件,以确保所有视图都有正确的位置和大小。你可以使用布局编辑器或手动编辑 XML 文件来添加约束条件。 例如,如果你的视图是一个按钮,你可以通过以下方式添加约束条件: 1. 在布局编辑器中选中按钮视图。 2. 点击约束布局编辑器中的“约束到父容器”按钮,或拖动约束线将按钮与父容器的顶部、左侧、右侧和底部约束。 3. 在 XML 文件中,确保按钮视图有以下属性: ```xml app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" ``` 这些属性指定了按钮视图与其父容器的约束条件。 如果你有多个视图需要约束,你需要确保它们之间没有冲突的约束条件。你可以使用布局编辑器中的“约束分析器”或手动编辑 XML 文件来解决冲突。

相关推荐

The starting configuration of this puzzle is a row of cells, with disks located on cells through . The goal is to move the disks to the end of the row using a constrained set of actions. At each step, a disk can only be moved to an adjacent empty cell, or to an empty cell two spaces away if another disk is located on the intervening square. Given these restrictions, it can be seen that in many cases, no movements will be possible for the majority of the disks. For example, from the starting position, the only two options are to move the last disk from cell to cell , or to move the second-to-last disk from cell to cell . 1. [15 points] Write a function solve_identical_disks(length, n) that returns an optimal solution to the above problem as a list of moves, where length is the number of cells in the row and n is the number of disks. Each move in the solution should be a twoelement tuple of the form (from, to) indicating a disk movement from the cell from to the cell to. As suggested by its name, this function should treat all disks as being identical. Your solver for this problem should be implemented using a breadth-first graph search. The exact solution produced is not important, as long as it is of minimal length. Unlike in the previous two sections, no requirement is made with regards to the manner in which puzzle configurations are represented. Before you begin, think carefully about which data structures might be best suited for the problem, as this choice may affect the efficiency of your search

class ConstrainedList (list): """Constrains the list class so it offers only the following primitive array API: - lst[i] for getting and setting a value at an *existing, positive* index i - len(lst) to obtain the number of slots - lst.append(None) to grow the list by *one slot at a time* - del lst[len(lst)-1] to delete the last slot in a list All other operations will result in an exception being raised. """ def __init__(self, *args): super().__init__(*args) def append(self, value): if value is not None: raise ValueError('Can only append None to constrained list!') super().append(value) def __getitem__(self, idx): if idx < 0 or idx >= len(self): raise ValueError('Can only use positive, valid indexes on constrained lists!') return super().__getitem__(idx) def __setitem__(self, idx, value): if idx < 0 or idx >= len(self): raise ValueError('Can only use positive, valid indexes on constrained lists!') super().__setitem__(idx, value) def __delitem__(self, idx): if idx != len(self)-1: raise ValueError('Can only delete last item in constrained list!') super().__delitem__(idx) def __getattribute__(self, name): if name in ('insert', 'pop', 'remove', 'min', 'max', 'index', 'count', 'clear', 'copy', 'extend'): raise AttributeError('Method "' + name + '" not supported on constrained list!') else: return super().__getattribute__(name) # __getattribute__ isn't called for special methods, so the following are needed def __add__(self, value): raise AttributeError('Constrained lists do not support +!') def __contains__(self, value): raise AttributeError('Constrained lists do not support in!') def __eq__(self, value): raise AttributeError('Constrained lists do not support ==!') def __iter__(self): raise AttributeError('Constrained lists do not support iteration!') def __str__(self): raise AttributeError('Constrained lists do not support stringification!') def __repr__(self): raise AttributeError('Constrained lists do not support stringification!') # for testing only! (don't use this in your ArrayList implementation) def _as_list(self): return list(super().__iter__())

最新推荐

recommend-type

Trajectory modification considering dynamic constraints of autonomous robots.pdf

The classic "elastic band" deforms a path generated by a global planner with respect to the shortest path length while avoiding contact with obstacles. It does not take any dynamic constraints of the ...
recommend-type

网络安全network-security-mind-map.zip

【资源简介】 第一章 网络安全概述 第二章 扫描与防御技术 第三章 网络监听及防御技术 第四章 口令破解与防御技术 第五章 欺骗攻击及防御技术 第六章 拒绝服务攻击与防御技术 第七章 缓冲区溢出攻击及防御技术 第八章 Web攻击及防御技术 第九章 木马攻击与防御技术 第十章 计算机病毒 第十一章 网络安全发展及未来
recommend-type

分布式锁与信号量.md

附件是分布式锁与信号量介绍和对比,文件绿色安全,请大家放心下载,仅供交流学习使用,无任何商业目的!
recommend-type

asp.net+sql2008在线论坛系统【ASP】.zip

asp.net+sql2008在线论坛系统【ASP】
recommend-type

h5py-2.7.0-cp35-cp35m-win_amd64.whl

Python库是一组预先编写的代码模块,旨在帮助开发者实现特定的编程任务,无需从零开始编写代码。这些库可以包括各种功能,如数学运算、文件操作、数据分析和网络编程等。Python社区提供了大量的第三方库,如NumPy、Pandas和Requests,极大地丰富了Python的应用领域,从数据科学到Web开发。Python库的丰富性是Python成为最受欢迎的编程语言之一的关键原因之一。这些库不仅为初学者提供了快速入门的途径,而且为经验丰富的开发者提供了强大的工具,以高效率、高质量地完成复杂任务。例如,Matplotlib和Seaborn库在数据可视化领域内非常受欢迎,它们提供了广泛的工具和技术,可以创建高度定制化的图表和图形,帮助数据科学家和分析师在数据探索和结果展示中更有效地传达信息。
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

MATLAB结构体与对象编程:构建面向对象的应用程序,提升代码可维护性和可扩展性

![MATLAB结构体与对象编程:构建面向对象的应用程序,提升代码可维护性和可扩展性](https://picx.zhimg.com/80/v2-8132d9acfebe1c248865e24dc5445720_1440w.webp?source=1def8aca) # 1. MATLAB结构体基础** MATLAB结构体是一种数据结构,用于存储和组织相关数据。它由一系列域组成,每个域都有一个名称和一个值。结构体提供了对数据的灵活访问和管理,使其成为组织和处理复杂数据集的理想选择。 MATLAB中创建结构体非常简单,使用struct函数即可。例如: ```matlab myStruct
recommend-type

详细描述一下STM32F103C8T6怎么与DHT11连接

STM32F103C8T6可以通过单总线协议与DHT11连接。连接步骤如下: 1. 将DHT11的VCC引脚连接到STM32F103C8T6的5V电源引脚; 2. 将DHT11的GND引脚连接到STM32F103C8T6的GND引脚; 3. 将DHT11的DATA引脚连接到STM32F103C8T6的GPIO引脚,可以选择任一GPIO引脚,需要在程序中配置; 4. 在程序中初始化GPIO引脚,将其设为输出模式,并输出高电平,持续至少18ms,以激活DHT11; 5. 将GPIO引脚设为输入模式,等待DHT11响应,DHT11会先输出一个80us的低电平,然后输出一个80us的高电平,
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。