为什么AndroidStudio会显示警告“从未使用过命名空间声明”?

这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:orientation="horizontal" >
</LinearLayout>

android official training

在第二行中,AndroidStudio显示此警告:

Namespace declaration is never used

为什么会这样?

谢谢.

解决方法

这是因为您没有在xml中实际声明的工具命名空间.

查看android命名空间,你有3个元素与该命名空间,但没有工具.

命名空间工具(http://schemas.android.com/tools)用于GUI设计器,不用于在Android设备上运行应用程序,因此您可以安全地删除它.

相关文章

ADB Remote ATV Android TV 的遥控器,基于 ADB Shell 命令 ...
使用Flutter自带的SearchDelegate组件实现搜索界面,通过魔改...
上篇文章讲解了怎么使用Kotlin的协程配合Retrofit发起网络请...
安卓开发——WebView+Recyclerview文章详情页,解决高度...
Android 如何解决dialog弹出时无法捕捉Activity的back事件 在...