简体   繁体   中英

uri is not registered http://schemas.android.com/apk/res/android

I am getting uri is not registered on my code.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <ProgressBar
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_gravity="center"
        android:id="@+id/progressBar1"/>

    <WebView
        android:id="@+id/webview01"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_weight="1">
    </WebView> 
</LinearLayout>

I have created a dir tabdir under the main/res/layout. and want to create xml file in tabdir.

If you create a sub directory, android studio will not recognize it as a standard resource directory. You can see the effect by changing project explorer mode from 'Project' to 'Android' in Android Studio.

在此处输入图片说明

在此处输入图片说明

Well, if you need to create a subdirectory, follow this SO thread. Or a quickfix to your error is to move your layout file to the main/res/layout directory.

New layout folders have to be added to sourceSet , otherwise the schemas won't be recognized. Here how to do it for gradle guys:

project grade file

sourceSets {
    main {
        //add folders following order from leafs to root. 
        res.srcDirs = [
                'src/main/res/layouts/layout_controls/layout_new_control',
                'src/main/res/layouts/layout_controls',
                'src/main/res/layouts/layout_main',
                'src/main/res']
    }

Each folder declared must have at least a sub folder named layout .

Other sub folders may be added to hold different type of resources for the new source the same way there are sub folders to res folder, eg values sub folder can be added to hold strings translations in a strings.xml file.

The content of layout_new_control folder would be something like:

-- layout
     new_control.xml
-- values
     strings.xml

The errors will only disappear after compile.

For more check this guide .

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