简体   繁体   中英

My Android Studio cannot find http://schemas.android.com/apk/res/android

I use Android Studio 2.2.3 and I try to develop an app with tab. But app's xml code has URL error. I type this code as below:

<?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>

and I press Make Project button. But my Android Studio says:

Error:(2) No resource identifier found for attribute 'context' in package 'com.example.hojune.prealpha_qna'
Error:(2) No resource identifier found for attribute 'context' in package 'com.example.hojune.prealpha_qna'

and it says "URL is not registerd" in the code below:

"http://schemas.android.com/apk/res/android"
"http://schemas.android.com/apk/res-auto"

But other files are working well. Please tell me what I should do.

创建一个新项目并查看布局xml中的url并将当前替换为它们

The context attribute belongs to tools namespace. Add tools namespace as below:

xmlns:tools="http://schemas.android.com/tools"

and replace app:context with tools:context .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM