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' ...
随机推荐
- grb文件的读取
grb文件的读取(转自:http://blog.sciencenet.cn/blog-922140-713837.html) read_grib.r4.rar 今天来斟酌了下grb文件格式的读取,现在 ...
- 转载-smarty教程(基本语法)
转自:http://hi.baidu.com/qxxgvpdtzhbckpr/item/681049160d7be60db98a1aec 1.smarty的配置 首先,使用smarty第一件 ...
- 编写一个jsp页面,输出九九乘法表。
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"% ...
- testng 注解
testng.xml suite(套件): 由一个或多个测试组成 test(测试): 由一个或多个类组成 class(类): 一个或多个方法组成 @BeforeSuite: 在某个测试套件开始之 ...
- Spring mvc get和post传值乱码问题
1.url拼值 传单值 对象 list map都是用json的格式传入后台 <%@ page language="java" contentType="text/ ...
- Oracle的dmp文件的导入
项目开始拿到了dmp文件,数据库用的是10g的,但是尽然没导成功,后来想可能导出的时候用11导出的,决定试一下. 正好自己的机器是11的客户端,结果不识别imp命令,到安装目录下的bin文件夹下看尽然 ...
- mini2440触摸屏驱动分析
mini2440驱动分析系列之 ---------------------------------------Mini2440触摸屏程序分析 By JeefJiang July,8th,2009 这是 ...
- 洛谷P1294 高手去散步
洛谷1294 高手去散步 题目背景 高手最近谈恋爱了.不过是单相思.“即使是单相思,也是完整的爱情”,高手从未放弃对它的追求.今天,这个阳光明媚的早晨,太阳从西边缓缓升起.于是它找到高手,希望在晨读开 ...
- HW3.20
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- 第一个php网页
<?php date_default_timezone_set('PRC'); if($_POST[ok]) { //echo "记录"; //echo "here ...