解决异常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版本的不报错,这就是后续版本的改进吗?

目录
相关文章
|
1月前
|
前端开发 Java Maven
解决ServletException: Circular view path异常的方法
解决`ServletException: Circular view path`异常涉及检查视图路径配置、请求处理逻辑、依赖版本冲突,以及使用重定向、注意`forward`和`include`的使用。检查代码中是否存在循环调用并修正,参考Spring MVC文档和Stack Overflow相关问题。
26 1
|
11月前
target\surefire-reports for the individual test results
target\surefire-reports for the individual test results
587 0
|
21天前
|
Java Maven
CoreException: Could not get the value for parameter compilerId for plugin execution default-compile
CoreException: Could not get the value for parameter compilerId for plugin execution default-compile
15 0
No module factory available for dependency type: ModuleHotAcceptDependency
No module factory available for dependency type: ModuleHotAcceptDependency
290 0
|
5月前
(node)Warning: Accessing non-existent property ‘xxx‘ of module exports inside circular depen
(node)Warning: Accessing non-existent property ‘xxx‘ of module exports inside circular depen
|
6月前
|
设计模式 JavaScript 测试技术
什么是 Angular 基于 Constructor Parameter 的 Dependency Injection
什么是 Angular 基于 Constructor Parameter 的 Dependency Injection
34 0
|
8月前
|
资源调度 JavaScript 前端开发
如何解决 Angular custom library module 在 ng build 时无法被识别的错误
如何解决 Angular custom library module 在 ng build 时无法被识别的错误
46 0
|
9月前
UVa1584 - Circular Sequence
UVa1584 - Circular Sequence
24 0
Angular ERROR NullInjectorError: R3InjectorError(AppModule)的错误分析
Angular ERROR NullInjectorError: R3InjectorError(AppModule)的错误分析
575 0
Angular ERROR NullInjectorError: R3InjectorError(AppModule)的错误分析
SpringCloud - Circular placeholder reference ‘xxx‘ in property definitions
SpringCloud - Circular placeholder reference ‘xxx‘ in property definitions
820 0