解决异常Circular dependencies cannot exist in RelativeLayout

简介: 解决异常Circular dependencies cannot exist in RelativeLayout

今天碰到这个error:

E/AndroidRuntime( 4657): Uncaught handler: thread main exiting due to uncaught e
xception
E/AndroidRuntime( 4657): java.lang.IllegalStateException: Circular dependencies
cannot exist in RelativeLayout

有点郁闷,我用的是skd1.5,在1.5的机器上(HTC G3)已经测试过了,没有问题的,但放在华为c8500(2.1update)上就报上面的错了,怎么回事呢?

根据提示判断应该是布局的原因,于是找到RelativeLayout的布局,找出最可疑的那个,注释后,不报错了。好就是他的原因,挨个看里面的元素,看属性,没错啊,后来发现,

<RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentRight="true">
<TextView android:id="@+id/titleName" android:text="首页"
android:textColor="@color/white" android:layout_toLeftOf="@+id/homeBtn"
android:layout_marginRight="2px"
android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<ImageButton android:id="@+id/homeBtn"
android:layout_toRightOf="@+id/titleName" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:src="@drawable/main"
android:background="@null" android:layout_marginRight="10px">
</ImageButton>
</RelativeLayout>


后来改成:

<RelativeLayout android:layout_width="wrap_content" android:layout_marginRight="10px"
android:layout_height="wrap_content" android:layout_alignParentRight="true">
<TextView android:id="@+id/titleName" android:text="首页"
android:textColor="@color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
<ImageButton android:id="@+id/homeBtn"
android:layout_marginLeft="2px" android:layout_marginTop="2px"
android:layout_toRightOf="@+id/titleName" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:src="@drawable/main"
android:background="@null" >
</ImageButton>
</RelativeLayout>


能看到区别吗?对就是在titleName中去掉了相对homeBtn的位置信息。再看看报错提示,人家说我在RelativeLayout中存在循环的相关,就是说的这个了。

不过1.5版本的不报错,这就是后续版本的改进吗?

目录
相关文章
LeetCode 电话号码的字母组合
LeetCode 电话号码的字母组合
303 0
LeetCode 电话号码的字母组合
|
8天前
|
域名解析 人工智能 Linux
|
18天前
|
Linux Go 开发工具
手机上跑 DeepSeek 智能体:开源安卓客户端 DSH Go 安装与使用指南
DSH Go 是一款开源安卓客户端,将 DeepSeek Harness 智能体引擎装进手机:免 Root、免 Termux,一键安装即用;支持本机运行(内置 Ubuntu+Node.js)或远程接管电脑会话;具备插话打断、过程折叠、屏幕操控、端到端加密分享等特色功能,真正实现智能体“口袋化”。
16788 62
|
16天前
|
人工智能
Google 提示「所在地区不可用」?进不去 Antigravity 或 Gemini,先查账号这个设置
进不去 Antigravity 或 Gemini,提示所在地区不可用?三步查清 Google 账号关联地区、官方更正表单理由选法与改区注意事项。
Google 提示「所在地区不可用」?进不去 Antigravity 或 Gemini,先查账号这个设置
|
2天前
|
人工智能 安全 网络安全
|
5天前
|
云安全 数据采集 人工智能
|
6天前
|
Linux API iOS开发
【DSH】DeepSeek Harness新手保姆教程(下载+安装+配置+使用,2026最新实测)
DeepSeek Harness(dsh)是 DeepSeek AI 开源的智能体框架,秉持“一切皆插件”理念,支持读文件、改代码、执行命令、处理表格等自动化任务;免费开源,兼容 Win/macOS,需配 API 密钥使用。(239字)
1203 2
|
13天前
|
人工智能 开发工具 开发者
2026最新codex下载安装保姆级使用教程(下载+安装+登录+使用,含所有历史版本)
Codex 是 OpenAI 推出的开源 AI 编程智能体,跑在本地终端和桌面客户端里,能读懂整个代码仓库,一句自然语言就能让它改代码、执行命令、跑测试、修 Bug,支持 Windows、macOS、Linux 三大平台。本文把 Codex下载、安装、登录、汉化、基础使用一次讲全,并整理了国内用户最常踩的坑,跟着做 10 分钟就能跑起来。
2282 7