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 ...
随机推荐
- svn checkout时连接不到服务器,重装也没有弹出用户名和密码输入框的问题
用公司的电脑,是win7 64位的系统,可以checkout出东西.现在用自己的电脑上,系统是win7 64位的,却再也连不上SVN. 1.不提示输入用户名和密码,不管重装多少次都一样. 2.Tort ...
- [转]ClassPath是什么
from: https://my.oschina.net/GivingOnenessDestiny/blog/603505 classpath 是什么classpath实际上就是编译后的 以 clas ...
- OpenGL进阶之Instancing
Instancing Instancing绘制我想很多童鞋都不陌生,这个技术主要用来快速渲染大量相同的几何体,可以大大提高绘制效率.每个instance在shader中都有一个独一无二的索引,可以用来 ...
- 机器学习——XGBoost
基础概念 XGBoost(eXtreme Gradient Boosting)是GradientBoosting算法的一个优化的版本,针对传统GBDT算法做了很多细节改进,包括损失函数.正则化.切分点 ...
- 数据库和AI的一次火花
欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 本文由宗文 发表于云+社区专栏 | 导语 通过历史数据,基于时间序列来预测未来. 我们生活中很多数据是有时间维度的.比如说天气或者股票价格. ...
- 【tomcat】关于tomcat的使用:将tomcat加入系统服务列表
一.下载TOMCAT 选择合适的版本进行下载: http://tomcat.apache.org/ 解压zip文件得到tomcat目录: 二.添加CATALINA_HOME到环境变量 service. ...
- 关于C#的Lock锁思考
大家都知道多线程并发时候存在一个线程同步的问题,一般使用lock关键字来处理. lock关键字的结果如下: object locker=new object(); lock(locker) { ... ...
- Linux 启动SVN服务
#使用默认端口3690启动svn服务svnserve -d -r /home/svndata # 如果出现#svnserve: Can't bind server socket: Address al ...
- TensorFlow入门:安装常用的依赖模块
TensorFlow运行中常用到一些Python第三方模块: numpy 存储和处理大型矩阵的科学计算包 maplotlib 最著名的绘图库 jupyter scikit-image 图像预处理 li ...
- Spring Cloud Ribbon负载均衡配置类放在Spring boot主类同级增加Exclude过滤后报Field config in com.cloud.web.controller.RibbonConfiguration required a bean of type 'com.netflix.client.config.IClientConfig' that could not b
环境: Spring Cloud:Finchley.M8 Spring Boot:2.0.0.RELEASE 目录结构: 可以看到代码第13行的注释,我已经在@ComponentScan注解中添加了E ...