error: Error: No resource found that matches the given name (at 'layout_above' with value '@id/btnLayout').
今天在练习fragment碎片的时候,进行界面布局的时候出现了这个问题。
后来解决后发现原因很简单:就是因为在布局xml文件中,引用ID和声明ID的顺序必须保证声明在前,引用在后。和布局的顺序无关。
【声明ID——android:id="@+id/btnLayout"。引用ID——android:layout_above="@id/btnLayout"】
出现错误的代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.why.practice.viewpagerfragment1.MainActivity" > <FrameLayout
android:id="@+id/fragmentLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_above="@id/btnLayout"
android:layout_centerHorizontal="true">
</FrameLayout> <LinearLayout
android:id="@+id/btnLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"> <Button
android:id="@+id/btn_one"
android:layout_width="0.0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="5dp"
android:text="@string/btn_oneText"
android:background="#009eff"
android:textColor="#fff"
style="?android:attr/buttonBarButtonStyle"
/> <Button
android:id="@+id/btn_two"
android:layout_width="0.0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="5dp"
android:text="@string/btn_twoText"
android:background="#009eff"
android:textColor="#fff"
style="?android:attr/buttonBarButtonStyle"
/>
<Button
android:id="@+id/btn_three"
android:layout_width="0.0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="5dp"
android:text="@string/btn_threeText"
android:background="#009eff"
android:textColor="#fff"
style="?android:attr/buttonBarButtonStyle"
/> </LinearLayout> </RelativeLayout>
正确的代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.why.practice.viewpagerfragment1.MainActivity" > <LinearLayout
android:id="@+id/btnLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"> <Button
android:id="@+id/btn_one"
android:layout_width="0.0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="5dp"
android:text="@string/btn_oneText"
android:background="#009eff"
android:textColor="#fff"
style="?android:attr/buttonBarButtonStyle"
/> <Button
android:id="@+id/btn_two"
android:layout_width="0.0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="5dp"
android:text="@string/btn_twoText"
android:background="#009eff"
android:textColor="#fff"
style="?android:attr/buttonBarButtonStyle"
/>
<Button
android:id="@+id/btn_three"
android:layout_width="0.0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="5dp"
android:text="@string/btn_threeText"
android:background="#009eff"
android:textColor="#fff"
style="?android:attr/buttonBarButtonStyle"
/> </LinearLayout> <FrameLayout
android:id="@+id/fragmentLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_above="@id/btnLayout"
android:layout_centerHorizontal="true">
</FrameLayout> </RelativeLayout>
error: Error: No resource found that matches the given name (at 'layout_above' with value '@id/btnLayout').的更多相关文章
- error:No resource found that matches the given name 'Theme.AppCompat.Light'
一.stsckoverflow http://stackoverflow.com/questions/17870881/cant-find-theme-appcompat-light-for-new- ...
- android中出现Error retrieving parent for item: No resource found that matches the Theme.AppCompat.Light
styles.xml中<style name="AppBaseTheme" parent="Theme.AppCompat.Light">提示如下错 ...
- error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCom ...
- 【android】新手容易遇到的[error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.]Theme出错的问题
一.概述 近期刚接手了一个项目,开发工具为eclipse,由于版本较低,且考虑到如果转android studio项目的话,会其他人的维护带来困难,所以想着还是维护项目原来的开发环境吧. 但是导入项目 ...
- eclipse新建项目,报错“Error: workspace\appcompat_v7\res\values-v21\styles_base.xml No resource found that matches the given name”
新建项目报错,不知道为什么,以前从未出现过的错误,把sdk更新之后,出现莫名错误,自己也是一知半解,在网上找了好久的错误,终于在一个english网站找到了解决方法,soga,从未觉得english如 ...
- error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.,appcompatv7
error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCom ...
- 【转】eclipse新建项目,报错“Error: workspace\appcompat_v7\res\values-v21\styles_base.xml No resource found that matches the given name”
原文网址:http://www.cnblogs.com/mbp-study/p/5268478.html 新建项目报错,不知道为什么,以前从未出现过的错误,把sdk更新之后,出现莫名错误,自己也是一知 ...
- error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton'.
引用appcompat 类库提示 error: Error retrieving parent for item: No resource found that matches the given ...
- Error: No resource found that matches the given name (at 'icon' with value '@mipmap/Icon')
问题: error: Error: No resource found that matches the given name (at 'icon' with value '@mipmap/Icon' ...
随机推荐
- Wordpress Jigoshop插件路径泄露漏洞
漏洞名称: Wordpress Jigoshop插件路径泄露漏洞 CNNVD编号: CNNVD-201311-109 发布时间: 2013-11-12 更新时间: 2013-11-12 危害等级: ...
- golang安装卸载 linux+windows+raspberryPI 平台
参考 https://golang.org/doc/install 自ECUG2013洗脑回来,就渴望早点接触Go 听着许式伟和谢孟军的演讲 发现go的网络库的确很强大,高负载利器,语言的一些精简导 ...
- 在C#中设置打印机纸张大小
using System.Drawing.Printing.PrintDocument using System.Drawing.Printing.PrinterSettings.PaperSizeC ...
- 读取编码为utf-16le的文件并打印
import codecs data = open('test.txt').read()if data[:2] == codecs.BOM_UTF16_LE: data = data[2:] ...
- oracle to_date函数(转载)
TO_DATE格式(以时间:2007-11-02 13:45:25为例) Year: yy two digits 两位年 ...
- grep环境变量常用配置
vim ~/.bashrc GREP_OPTIONS="-irns --exclude-dir=output --exclude=tags --exclude=*.files" 然 ...
- 非阻塞,send后马上close消息能成功发出去吗
send返回成功的话就能. 判断send返回,假如返回的值是成功,则说明要发送的放到了tcp的发送缓冲区内了,然后在close的话等于再放了一个关闭信号到缓冲区里的. 由于TCP是有序的,假如对端此时 ...
- HW2.9
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- Solution for When browse http://xxx/ReportServer Show Error (rsAccessDenied)
Issue: Reporting Services Error The permissions granted to user 'IDEAAM\William' are insufficient fo ...
- openstack 制作大于2TB根分区自动扩容的CENTOS镜像
制作镜像的时候默认分的是30G空间 qemu-img create -f raw centos.img 30G 看官网文档安装完系统需要安装cloud-init和clout-utils包,本人安装了完 ...