开发问题及解决--java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout
2015-07-07 10:19
666 查看
今天使用Scrollview 和HorizontalScrollview 嵌套显示时,使用如下布局:
爆出了这样的异常,java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout。
原因就是在RelativeLayout布局中重现了重复的view ID名称,且出现 imageview2 ,textview3,imageview2出现了循环依赖。
解决方案: 将最后一个ImageView的id修改成 imageview3. 避免在RelativeLayout中控件循环依赖。
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" > <HorizontalScrollView android:layout_width="fill_parent" android:layout_height="wrap_content" > <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:id="@+id/textview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图" android:textSize="30dp" /> <ImageView android:id="@+id/imageview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/textview1" android:src="@drawable/item1" /> <TextView android:id="@+id/textview2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/imageview1" android:text="垂直和水平滚动" android:textSize="30dp" /> <ImageView <span style="color:#ff6666;">android:id="@+id/imageview2" </span> android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/textview1" android:src="@drawable/item2" /> <TextView android:id="@+id/textview3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/imageview2" android:text="垂直和水平滚动" android:textSize="30dp" /> <ImageView <span style="color:#ff6666;"> android:id="@+id/imageview2"</span> android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/textview3" android:src="@drawable/item3" /> </RelativeLayout> </HorizontalScrollView> </ScrollView>
爆出了这样的异常,java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout。
原因就是在RelativeLayout布局中重现了重复的view ID名称,且出现 imageview2 ,textview3,imageview2出现了循环依赖。
解决方案: 将最后一个ImageView的id修改成 imageview3. 避免在RelativeLayout中控件循环依赖。
相关文章推荐
- ubuntu中安装eclipse
- Spring4 与 Hibernate4 整合过程中的问题记录
- Spring 使用注解方式进行事务管理
- Java 运算符优先级
- Eclipse 常用快捷键 (动画讲解)
- Java String.split()用法小结
- Java保留两位小数的几种做法
- Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently
- 关于java使用jacob调用word,ppt,excel等的转化为html的问题
- 将16进制字符串转换为整数输出
- Java基础日记———IO流(上)
- java自带的MD5、SHA1算法演示
- Java 判断文件夹、文件是否存在、否则创建文件夹
- jdk的环境配置方法
- #笔记#圣思园 JavaWeb 第23讲——JavaBean
- Myeclipse SVN插件使用
- java异常处理
- Java实现 Base64、MD5、MAC、HMAC加密(转)
- java I/O学习
- Java - How Classpath works in Java