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' ...
随机推荐
- BZOJ_1618_ [Usaco2008_Nov]_Buying_Hay_购买干草(动态规划,完全背包)
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1618 有n种物品,每种物品有价值和重量,可以无限拿.现在要满足价值之和大于等于h,问最小重量. ...
- LoadLibraryEx及发回hmodule的一些细节
LoadLibraryEx可以配合 DONT_RESOLVE_DLL_REFERENCES LOAD_LIBRARY_AS_DATAFILE LOAD_LIBRARY_AS_DATAFILE_EXCL ...
- How to Customize Server Header using NginX headers-more module
http://wiki.nginx.org/HttpHeadersMoreModule#Version headers_more When you are browsing a website, yo ...
- Azure Backup 入门
Viswanath Tata 云 + Enterprise项目经理 Azure Backup是一款允许客户将数据备份到 Azure的强大工具.请参阅这篇文章,快速了解 Azure Backup.我 ...
- 编写一个jsp页面,输出九九乘法表。
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"% ...
- testng 注解
testng.xml suite(套件): 由一个或多个测试组成 test(测试): 由一个或多个类组成 class(类): 一个或多个方法组成 @BeforeSuite: 在某个测试套件开始之 ...
- html总结----------------------看这个就够了
HTML是我们学习Javaweb的第一步 很好地掌握门课是非常有必要的!下面就是我在听资深老师讲课的笔记!个人觉得非常不错!希望可以帮助到那些在学习javaweb路上的 朋友们!从今天 陆续的整理这门 ...
- Sublime Text 2使用心得
一个比较详细的文章:http://www.cnblogs.com/figure9/p/sublime-text-complete-guide.html 一. 前言 作为一个前端,有一款好的开发利器是必 ...
- HIbernate学习笔记(一) 了解hibernate并搭建环境建立第一个hello world程序
Hibernate是一个开放源代码的ORM(对象关系映射)框架,它对JDBC进行了轻量级的封装,Java程序员可以使用面向对象的编程思维来操纵数据库,它通过对象属性和数据库表字段之间的映射关系,将对象 ...
- HW2.15
public class Solution { public static void main(String[] args) { double rate = 0.05; double balance ...