5

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.

2 Answers2

2

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.

enter image description here

enter image description here

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.

Community
  • 1
  • 1
Jay Rathod
  • 97
  • 1
  • 2
  • 9
1

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, e.g. 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.

MiguelSlv
  • 14,067
  • 15
  • 102
  • 169