我只是清理了我的.xml文件并外包了每个文件的页眉和页脚元素.之后我的projekt遇到错误,但只有8个文件中的2个.
旧代码:
<ImageView
android:layout_width = "wrap_content"
android:id = "@+id/ImageView01"
android:layout_height = "60dp"
android:src = "@drawable/logo"
android:scaleType = "fitXY">
Run Code Online (Sandbox Code Playgroud)
和新代码:
<include layout="@layout/header" /
Run Code Online (Sandbox Code Playgroud)
错误显示"找不到与给定名称匹配的资源('layout_below',值为'@id/searchRelativeLayout')
<LinearLayout
android:id = "@+id/SearchRelativeLayout"
android:layout_width = "fill_parent"
android:layout_height = "wrap_content"
android:orientation = "horizontal"
android:layout_below = "@id/ImageView01"
android:gravity = "center"
android:layout_marginTop = "5dip"
android:paddingRight = "5dip"
android:paddingLeft = "5dip">
Run Code Online (Sandbox Code Playgroud)
我无法想象为什么它几乎适用于所有文件但不适用于这两种文件.它只是复制和粘贴,其余的都是一样的.
这个真的让我思考了很多,最后不相信......
我使用完全相同的问题的RelativeLayout与包括
在我的.xml文件的一部分中,我可以引用include中的id.在其他人没有.
layout_head.xml包含要包含的布局.我使用了以下声明:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" style="@style/ETActivity">
<include android:id="@+id/cell1" layout="@layout/aalayout_head" />
<ListView android:id="@+id/main_list" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_below="@id/layout_spacer" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我看到这适用于每个xml文件,该文件按字母顺序排列在layout_head.xml下面.所以我将layout_head.xml重命名为aalayout_head.xml,当然将include语句切换为新名称 - et voila - 适用于每个文件......
似乎是Eclipse插件而不是Android系统本身的问题.
Wierd enoug但幸运的是它现在正在完美地工作.
顺便说一句:当我使用android时,我知道为什么我的布局不起作用:layout_below ="@ id/cell1"?
| 归档时间: |
|
| 查看次数: |
606 次 |
| 最近记录: |