RelativeLayout布局id找不到的问题
来源:互联网 发布:怎样安装天正软件 编辑:程序博客网 时间:2024/05/01 00:20
最近犯过几次这样的错。
在RelativeLayout布局里,有两个控件,如图:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#4CBAEB"> <TextView android:id="@+id/tv_xiala" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="20dp" android:text="下拉刷新" android:textColor="@color/white" android:textSize="30sp" /> <ImageView android:id="@+id/img_jiantou" android:layout_width="40dp" android:layout_height="40dp" android:layout_marginTop="15dp" android:layout_toLeftOf="@id/tv_xiala" android:background="@drawable/head_me" /></RelativeLayout>
第一个控件是 TextView,id是tv_xiala
第二个控件是ImageView,id是img_jiantou
因为在第二个控件里用到了第一个控件的id
android:layout_toLeftOf=”@id/tv_xiala”
所以第二个控件必须写在第一个控件的下边,因为安卓读取布局的时候是从上往下读的,如果放在上面就会出现找不到id的情况啦。
所以如果用到
android:layout_toLeftOf
android:layout_toRightOf=””
android:layout_above=””
android:layout_below=””
这些属性的时候要小心啦。虽然不是什么大问题,但是记录一下,巩固一下知识吧。
0 0
- RelativeLayout布局id找不到的问题
- android xml布局文件中使用RelativeLayout,明明有这个id,却提示找不到---->解决办法
- android xml布局文件中使用RelativeLayout,明明有这个id,却提示找不到---->解决办法
- RelativeLayout布局问题
- RelativeLayout的布局
- Relativelayout布局的bug
- RelativeLayout 布局的运用
- RelativeLayout布局的属性
- android编译找不到资源id的问题
- android R.id找不到资源的问题
- 解决RelativeLayout中 gone之后的布局错位问题。RelativeLayout的alignWithParentIfMissing
- 解决RelativeLayout中 gone之后的布局错位问题。RelativeLayout的alignWithParentIfMissing
- RelativeLayout中 gone之后的布局错位问题
- 解决RelativeLayout中gone后布局错位问题:RelativeLayout的alignWithParentIfMissing。
- 关于R.id.xxx或者R.layout.xxx找不到id或布局文件的解决方案
- RelativeLayout的一些布局属性
- 简单的RelativeLayout布局使用
- android的Relativelayout布局属性
- xcode的Targets选项下有Other linker flags的设置
- 虚拟内存、物理内存
- nginx笔记之fastcgi_param解释
- Ironic mitaka ReleaseNotes
- list of plugin
- RelativeLayout布局id找不到的问题
- 在eclipse里使用sun.net连接FTP服务器
- Angularjs 数据请求和数据,以及获取地址栏信息提交service
- 设置ListView item间距
- Java加密技术(二)——对称加密算法DES&AES
- 数据库TimeStamp
- [c++]最大流算法
- 整理的Swift 第三库
- Java Static关键字引发的思考