I'm a bit new to programming so bear with me. I'm trying to create a FAB menu by following ResoCoder's tutorial on youtube, but there's an issue with the CoordinatorLayout element being declared.
It throws this warning:
The 'android.support.design.widget.CoordinatorLayout' is not declared.
Here's the AXML file.
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Hello FAB menu!"
android:textSize="24sp"/>
<View
android:id="#+id/bg_fab_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#48000000"
android:alpha="0"
android:visibility="gone"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_airballoon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/standard_23"
android:visibility="gone"
android:rotation="90"
app:fabSize="mini"
app:srcCompat="#drawable/ic_airballoon"/>
</android.support.design.widget.CoordinatorLayout>
And here is an image of the warning.
Warning
edit:
This is now showing on the 'Designer' tab
Error on designer tab
Short Answer :
It's just a warning and not an error, you could compile your project without any problem.
Long Answer :
The problem is that the Intellisense could not pick the attributes you type although those attributes did exists in android SDK. So the Visual Studio shows that :
The 'android.support.design.widget.CoordinatorLayout' is not declared.
To solve this problem, you should enable Intellisense in Android .axml files. But a little difference with the document, you could download android-layout-xml.xsd and schemas.android.com.apk.res.android.xsd file from the following link :
https://github.com/atsushieno/monodroid-schema-gen/blob/master/android-layout-xml.xsd
https://github.com/atsushieno/monodroid-schema-gen/blob/master/schemas.android.com.apk.res.android.xsd
Download the file and edit the android-layout-xml.xsd and add the ConstraintLayout element. Then move these file manually to :
C:\Program Files (x86)\Microsoft Visual Studio 14.0\XML\Schemas\1033
Or simply just add these schemas within Visual Studio. Restart your VS, this warning will be gone
Suggestion :
It is recommend that ignoring the warning, you could compile your project without any problem.
Update :
Otherwise, after compiling I get errors like: 'Error: No resource found that matches the given name (at 'layout_margin' with value '#dimen/standard_23').' Which I assume are because of the CoordinatorLayout not being declared.
The dimen attribute need you create on yourself, make sure you copied the dimens.xml file too. You need create the dimens.xml in Resource\values\dimens.xml, define the standard_23 size in this file. Then the compile could find the standard_23 size.
dimen.xml :
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<dimen name="action_button_min_width">56dp</dimen>
<dimen name="indeterminate_progress_size">32dp</dimen>
<dimen name="standard_23">23dp</dimen>
</resources>
Related
So in my project, we are overriding a preferences layout file - preference_category_material.xml from androidx.preference:preference library.
Our new code of preference_category_material.xml looks something like this
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="UnusedResources"
android:id="#android:id/textView"
...
/>
The TextView is the root and the only element in the file.
While running ./gradlew lintRelease I am getting this error:
Error: Overriding #layout/preference_category_material which is marked as private in androidx.preference:preference:1.2.0. If deliberate, use tools:override="true", otherwise pick a different name. [PrivateResource]
I have seen a similar question, but that deals with color tags: Override resources in library android
Adding tools:override="true" to the TextView in our file does nothing.
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="UnusedResources"
tools:override="true"
android:id="#android:id/textView"
...
/>
This does not solve the problem.
Any help is appreciated. Thanks.
I've wanted to learn how to build apps and I found a course online that explains what to do. for that course I downloaded java jdk and android studio and I installed everything on default settings. from there I opened up a new project with blank page, and I got like 9 errors and the preview is not working as well. all my friends are not having this problem I don't know why I am. Here's the code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Home"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.android.com/tools
http://schemas.android.com/apk/res/android
http://schemas.android.com/apk/res/android ">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
The errors I get are:
"URI is no registered" (on the first 3 lines)
"Android_Width/Height/Tools is not allowed here" (thats 3 errors)
"Cannot resolve Symbol http://schemas.android.com/apk/res/android"
"Element textview is not allowed here"
Can someone please explain and help me solve this? I want to start building and learning but I cant seem to find the problem in here..
Also I tried reinstalling, re opening a project, adding the uri's to the schemas % dtd list and checking if I opened the debugging xml by mistake. the file is "activity_main.xml".
Thanks in advance :)
Have you declared constraint layout on app/build.gradle ?
1.Ensure you have the maven.google.com repository declared in your module-level
build.gradle file:
repositories {
google()
}
2.Add the library as a dependency in the same build.gradle file, as shown in the example below. Note that the latest version might be different than what is shown in the example:
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
}
3.In the toolbar or sync notification, click Sync Project with Gradle Files.
reference
when removing all the useless clutter, it should work:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
the definition of xsi:schemaLocation had duplicate and wrongful entries.
I was googling for ways of specifying Width and Height of views in Android.
I found
Xamarin.Android.Support.Percent library
Link to official example: https://components.xamarin.com/gettingstarted/xamandroidsupportpercent
I used package manager to obtain this library and copy pasted axml code from the example:
<?xml version="1.0" encoding="utf-8"?>
<android.support.percent.PercentFrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:background="#f0f0f0"
app:layout_widthPercent="50%"
app:layout_heightPercent="50%"
app:layout_marginTopPercent="25%"
app:layout_marginLeftPercent="25%" />
</android.support.percent.PercentFrameLayout>
It can't even compile, errors i get:
Severity Code Description Project File Line Suppression State Error No
resource identifier found for attribute layout_widthPercent,
layout_heightPercent, layout_marginTopPercent,
layout_marginLeftPercent
Does anyone has an idea of what is wrong?
I am pretty new to Xamarin and Android. Is there something I need to write in AndroidManifest.xml or AssemblyInfo.cs?
Any other advice?
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, 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.
I am using Android Studio 1.1 RC 1.
I've imported an external library into Gradle:
compile 'com.rengwuxian.materialedittext:library:1.8.3'
I've added the namespace tag:
xmlns:app="http://schemas.android.com/apk/res-auto"
into the parent as below:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/primary_light"
android:orientation="vertical"
android:padding="20dp"
tools:context="net.xxx.xxx.ui.activities.Activity"/>
I get code completion for the custom views within the library i.e.:
<com.rengwuxian.materialedittext.MaterialAutoCompleteTextView />
But nothing comes up when I try code completion for the attributes for this view. I have to type all this in manually.
<com.rengwuxian.materialedittext.MaterialAutoCompleteTextView
android:id="#+id/autocomplete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:completionThreshold="3"
android:hint="Enter name"
android:imeOptions="actionDone"
app:floatingLabel="normal"
app:floatingLabelText="Find xxx"/>
Is there a setting or import that I'm missing?
Helpful Info:
The attribute file in the library can be found here.
https://github.com/rengwuxian/MaterialEditText/blob/master/library/src/main/res/values/attrs.xml
I had the same issue. But I have solved it.
Go File > Invalidate Caches / Restart... > Click at Invalidate and Restart
It's an efficient way. You can try.
Source: Android Studio - Auto complete and other features not working
Note: Here are some other approaches too. Have a look.