java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/ItemIntr"
android:layout_toRightOf="@+id/ItemImage"
android:layout_below="@+id/ItemTitle"
android:layout_above="@+id/ItemText"
android:textSize="20sp"/>
出现错误java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout
经查找发现,是相对布局不支持这种依赖方式(为了清晰,我仅列出了出错的控件,控件间的关系间文末附上的正确代码)
于是,将android:layout_above="@+id/ItemText"删掉,程序正确运行
但是,将 android:layout_below="@+id/ItemTitle"删掉,程序依旧报此错误。
思考了一下,所谓“依赖循环”:
声明A的时候:A在B上面
声明B的时候:B在A下面
这就造成了所谓循环依赖,计算机无法识别你的布局要求,导致程序出现错误。
解释程序不报错,循环依赖是没必要的,同时也会使程序变得非常复杂,所以在以后自己开发程序的时候一定要注意这一点。
下面是正确的代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_width="fill_parent">
<ImageView
android:layout_alignParentLeft="true" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/ItemImage"/>
<TextView
android:id="@+id/ItemTitle"
android:layout_toRightOf="@+id/ItemImage"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textSize="20sp"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/ItemIntr"
android:layout_toRightOf="@+id/ItemImage"
android:layout_below="@+id/ItemTitle"
android:textSize="20sp"/>
<TextView
android:id="@+id/ItemText"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_toRightOf="@+id/ItemImage"
android:layout_below="@+id/ItemIntr"/>
</RelativeLayout>
java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout的更多相关文章
- 开发问题及解决--java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android=" ...
- android java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout
造成这个问题的原因是在xml文件中出现了重复依赖,何为重复依赖,如下: 以上便叫重复依赖 转载请标明出处:http://www.cnblogs.com/tangZH/p/8386978.html
- Circular dependencies cannot exist in RelativeLayout
循环布局错误!!! <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:an ...
- junit测试时,出现java.lang.IllegalStateException: Failed to load ApplicationContext
课程设计要求进行junit测试,我是在已经做好的ssh项目上做的测试,测试类代码如下 package com.zhang.web.services; import static org.junit.A ...
- java.lang.IllegalStateException: Failed to load ApplicationContext
1.错误描述 七月 13, 2014 6:34:41 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBean ...
- java.lang.IllegalStateException: Cannot run without an instance id.
启动springboot,报错:quartz集群报错: Sep 09, 2016 5:33:47 AM org.apache.catalina.core.ApplicationContext log ...
- tomcat启动报错:java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException:
tomcat日志: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start com ...
- Caused by: java.lang.IllegalStateException: Unable to complete the scan for annotations for web application [/Cppcc] due to a StackOverflowError. Possible root causes include a too low setting for -Xs
解决办法:(1)修改D:\Java\apache-tomcat-7.0.88\conf\catalina.properties (122line) (2)如org.apache.catalina.st ...
- tomcat启动时检测到循环继承而栈溢出的问题:Caused by: java.lang.IllegalStateException: Unable to complete the scan for annotations for web application [/test] due to a StackOverflowError. Possible root causes include
最近在公司更新一个老项目的时候,发现部署项目后tomcat报错,错误如下: Caused by: java.lang.IllegalStateException: Unable to complete ...
随机推荐
- unity摄像机移动滑动
之前写了一个pc版本的 // 当按住鼠标左键的时候 //if (Input.GetMouseButton(0)) //{ // // 获取鼠标的x和y的值,乘以速度和Time.deltaTime是因为 ...
- 使用 GitHub API 进行数据分析 (Node.js)
使用 GitHub API 进行数据分析 (Node.js) Node.js 的访问 GitHub 的 API 库,通过 npm 或者 yarn 安装: yarn add github-api 官方示 ...
- django 将表数据通过API展示到页面上(转)
需求: 我在learn这个app下创建了两张表,其中一个表为user,我希望通过API,在页面是展示这些数据,当用户访问指定的url时,将表中所有对象展示到页面上. 先看learn/models.py ...
- bzoj 5340: [Ctsc2018]假面
Description 题面 Solution 生命值范围比较小,首先维护每一个人在每个血量的概率,从而算出生存的概率,设为 \(a[i]\) 询问时,只需要考虑生存的人数,可以 \(DP\) 设 \ ...
- 深入理解JavaScript系列(26):设计模式之构造函数模式
介绍 构造函数大家都很熟悉了,不过如果你是新手,还是有必要来了解一下什么叫构造函数的.构造函数用于创建特定类型的对象——不仅声明了使用的对象,构造函数还可以接受参数以便第一次创建对象的时候设置对象的成 ...
- 浏览器后退->清除原页面div中填写的数据
需求说明:页面表单用前端用div布局,提交之后跳转到另一个页面,但是考虑到客户奇怪的脑回路,可能会点击浏览器的后退按钮,不知道是个体情况还是都是一样,原本div中填写的数据还依然存在,所以需要让页面在 ...
- .NET开源工作流RoadFlow-表单设计-子表
子表即明细表 从表:与主表对应在子表. 从表主键:从表的主键. 主表字段:主表中与从来关联的字段,一般为主表的主键. 与主表关联字段:从表中与主表关联的字段. 选择之后即可在下面从表字段列表中设置每个 ...
- Web安全入门笔记-XSS
windows 10 360浏览器 0x00.概述 1.什么是 XSS Cross-Site Scripting(跨站脚本攻击)简称 XSS,是一种代码注入攻击.攻击者通过在目标网站上注入恶意脚本,使 ...
- 【起航计划ObjC 002】印第安老斑鸠ObjC的幻想 ---- Ubuntu下安装并使用MAC虚拟机
本文介绍如何在Ubuntu下安装Mac OS X Mavericks系统.具体如下: 1)安装前准备工作 下载Mac OS X Mavericks系统,地址:http://pan.baidu.com/ ...
- linux下查看磁盘分区的文件系统格式
df -T 只可以查看已经挂载的分区和文件系统类型. Filesystem Type 1K-blocks Used Available Use% Mounted on/dev/sda1 ext4 20 ...