<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的更多相关文章

  1. 开发问题及解决--java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout

    <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android=" ...

  2. android java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout

    造成这个问题的原因是在xml文件中出现了重复依赖,何为重复依赖,如下:   以上便叫重复依赖 转载请标明出处:http://www.cnblogs.com/tangZH/p/8386978.html

  3. Circular dependencies cannot exist in RelativeLayout

    循环布局错误!!! <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:an ...

  4. junit测试时,出现java.lang.IllegalStateException: Failed to load ApplicationContext

    课程设计要求进行junit测试,我是在已经做好的ssh项目上做的测试,测试类代码如下 package com.zhang.web.services; import static org.junit.A ...

  5. java.lang.IllegalStateException: Failed to load ApplicationContext

    1.错误描述 七月 13, 2014 6:34:41 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBean ...

  6. java.lang.IllegalStateException: Cannot run without an instance id.

    启动springboot,报错:quartz集群报错: Sep 09, 2016 5:33:47 AM org.apache.catalina.core.ApplicationContext log ...

  7. tomcat启动报错:java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException:

    tomcat日志: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start com ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. Java for循环的几种用法分析

    J2SE 1.5提供了另一种形式的for循环.借助这种形式的for循环,可以用更简单地方式来遍历数组和Collection等类型的对象.本文介绍使用这种循环的具体方式,说明如何自行定义能被这样遍历的类 ...

  2. 03-struts2获得servetAPI

    1 原理 三个域合一的时候相同的键值对以小的域为准.ActionContext 对象创建:每次请求的时候都会创建一个与请求对应的 ActionContext 对象.ActionContext 销毁:请 ...

  3. mongodb慢查询记录

    在 MySQL中,慢查询日志是经常作为我们优化数据库的依据,那在MongoDB中是否有类似的功能呢?答案是肯定的,那就是Mongo Database Profiler.不仅有,而且还有一些比MySQL ...

  4. pom.xml无法引入本地的jar和安装到本地安装maven 错误: 找不到或无法加载主类 org.codehaus.plexus.classworlds.launcher.Launcher

    今天maven突然无法引入本地maven库的jar包,导致maven工程出错,然后就准备重装maven ,开始只是将环境变量删除,将之前的压缩包解压,再重新配置环境 变量,可是配置好后在dos窗口 输 ...

  5. DistinctBy

    如何很好的使用Linq的Distinct方法[全屏看文] Person1: Id=1, Name="Test1" Person2: Id=1, Name="Test1&q ...

  6. C# 使用cookie实现登录

    首先,我们需要做的是什么? 我们成功登录之后,跳转到主界面,然后主界面的登录按钮变成头像啥的.下一次打开网页就要判断有没有登录过,有cookie就不需要登录,直接显示头像 1.成功登录后,客户端请求服 ...

  7. C#使用第三方组件Epplus操作Excel表

    Epplus操作Excel基础详解 1.什么是Epplus Epplus是一个使用Open Office XML文件格式,能读写Excel2007/2010文件的开源组件,在导出Excel的时候不需要 ...

  8. Error creating bean with name 'com.cloud.feign.interfaces.xxxFeignClient': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalSt.PathVariable annotation was empty on

    环境: Spring Cloud:Finchley.M8 Spring Boot:2.0.0.RELEASE 报错信息: Error creating bean with name 'com.clou ...

  9. CRM——权限

    一.引入权限组件 1.引入权限组件rbac 拷贝之前写好的rbac应用到CRM_demo项目下. 在settings中注册rbac的app: INSTALLED_APPS = [ 'django.co ...

  10. 【代码笔记】Java——远程监控、反射、代理、内省机制

    远程控制的基本原理 远程控制(RemoteControl)拥有控制端和被控端双方. 控制方通过请求,取得对远端的操作,实现远端的事件回放功能,同时,应该看得到远端桌面的画面.而被控方必须在建立Serv ...