命名空间在 Android Studio 中未绑定 [英] Namespace is not Bound in Android Studio

查看:55
本文介绍了命名空间在 Android Studio 中未绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我创建一个新的 XML 文件(使用默认的 Android Studio创建线性布局"),Studio 会创建一个包含内容的文件:

If I create a new XML-file (using the default Android Studio "Create Linear Layout"), Studio makes a file with content:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

</LinearLayout>

如果我(右键)单击分析... → 检查代码",结果窗口将抛出 2 次:命名空间不受约束"以及对第 3 行和第 7 行(LinearLayout 标记)的引用.这是 Studio 中的错误吗?

If I (right)-click "Analyze... → Inspect Code" the result window throws 2 times: "Namespace is not bound" and references to line 3 and 7 (the LinearLayout-tags). Is it a bug in Studio?

推荐答案

如果出现错误:

未绑定命名空间工具":

Namespace 'tools' is not bound:

示例:

<activity
    android:name="com.google.android.gms.ads.AdActivity"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    tools:replace="android:theme"
    />

在清单(或活动)顶部添加 xmlns:tools="http://schemas.android.com/tools".

Add xmlns:tools="http://schemas.android.com/tools" at the top of the manifest (or activity).

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mypackage"
    xmlns:tools="http://schemas.android.com/tools">

这篇关于命名空间在 Android Studio 中未绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆