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

最新文章

  1. vue.js 批量删除跟全选,反选效果
  2. Java动手动脑(二)
  3. OpenGL 圆角矩形
  4. HDU 4630 No Pain No Game(树状数组)
  5. source命令
  6. postgresql异常快速定位
  7. .NET导入openssl生成的公钥之BEGIN RSA PUBLIC KEY
  8. lower_bound 和 upper_bound
  9. Model Browser
  10. iOS UIKit:TabBar Controller
  11. 在netcore中实现字段和属性注入
  12. HandlerMapping和HandlerAdapter配置须知
  13. ORACLE EBS常用表
  14. JMH使用说明
  15. 转载:从程序员的角度看ASCII, GB2312, UNICODE, UTF-8
  16. ie6 ie7 userdata 本地存储 引发的惨案.
  17. HDU1501 dfs
  18. virtualenv使用
  19. 解决 jsonP 安全问题
  20. php 常用字符集

热门文章

  1. cloudemanager安装时出现8475 MainThread agent ERROR Heartbeating to 192.168.30.1:7182 failed问题解决方法(图文详解)
  2. 【Unity】工具类系列教程—— 代码自动化生成!
  3. javascript中for in与in的用法
  4. SQL Server 数据库定时自动备份(转)
  5. 02.for循环
  6. DJango小总结二
  7. Web开发HTTP中URI和URL的情感纠葛
  8. JavaScript(Two)
  9. 今日头条极速版邀请码以及其它APP邀请码大全
  10. IntelliJ IDEA热部署教程,只要两步!