我的Android Studio找不到http://schemas.android.com/apk/res/android
我使用Android Studio 2.2.3,并尝试开发一个带有tab的应用程序。但应用程序的xml代码有URL错误。 我键入以下代码:我的Android Studio找不到http://schemas.android.com/apk/res/android,android,xml,Android,Xml,我使用Android Studio 2.2.3,并尝试开发一个带有tab的应用程序。但应用程序的xml代码有URL错误。 我键入以下代码: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://sche
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
app:context="com.example.hojune.prealpha_qna.MainActivity">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
android:background="?attr/colorPrimaryDark"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:elevation="1dp"
android:id="@+id/toolbar">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/Base.TextAppearance.Widget.AppCompat.Toolbar.Title"
android:text="Learning QnA"/>
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:tabMode="fixed"
app:tabGravity="fill"
app:tabTextColor="@color/colorPrimary"
app:tabSelectedTextColor="@color/colorAccent"
app:elevation="1dp"
android:background="@android:color/background_light"/>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container">
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
xmlns:tools="http://schemas.android.com/tools"
然后我按下“生成项目”按钮。但是我的Android工作室说:错误:(2)在包“com.example.hojune.prealpha_qna”中找不到属性“context”的资源标识符
错误:(2)在包“com.example.hojune.prealpha_qna”中找不到属性“context”的资源标识符
在下面的代码中显示“URL未注册”: "http://schemas.android.com/apk/res/android“
"http://schemas.android.com/apk/res-auto" 但其他文件运行良好。
请告诉我应该做什么。创建一个新项目,查看布局xml中的URL,并将当前URL替换为它们。上下文属性属于
工具
命名空间。添加工具
命名空间,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
app:context="com.example.hojune.prealpha_qna.MainActivity">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
android:background="?attr/colorPrimaryDark"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:elevation="1dp"
android:id="@+id/toolbar">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/Base.TextAppearance.Widget.AppCompat.Toolbar.Title"
android:text="Learning QnA"/>
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:tabMode="fixed"
app:tabGravity="fill"
app:tabTextColor="@color/colorPrimary"
app:tabSelectedTextColor="@color/colorAccent"
app:elevation="1dp"
android:background="@android:color/background_light"/>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container">
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
xmlns:tools="http://schemas.android.com/tools"
用
tools:context
替换app:context
尝试更新android studio和所有组件,但我使用了android编程书中的示例,我是按照书中的说明来做的。这是书中的错误,你可以从官方文档中找到更多工具xmlns的用法