这是我的布局:
<?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>
取自安卓官方培训
在第二行中,AndroidStudio 显示以下警告:
Namespace declaration is never used
为什么会这样?
谢谢。
这是因为您没有任何内容tools
命名空间实际上在xml中声明。
查看 android
命名空间,您有 3 个具有该命名空间的元素,但没有 tools
个元素。
命名空间tools
(http://schemas.android.com/tools) 用于 GUI 设计器,不用于在 Android 设备上运行应用,因此您可以安全地将其删除。
只需删除"xmlns:app="http://schemas.android.com/apk/res-auto"