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.
Related
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>
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 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.
I am trying to use PixlUI to implement custom fonts into my Android app using Xamarin. I've followed these steps:
Added a new Android Java Bindings Library to my main solution
Added pixlui-1-0-5.jar to the jars folder
Under properties for pixlui-1-0-5.jar i've set the "include in deploy" to true
Tested my new Android Java Bindings Library and it builds fine without errors
Under the main project i've added my font to the assets/fonts folder
Under references i've added the pixlUI binding library
In my main.axml i've placed this code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:pixlui="http://schemas.android.com/apk/com.neopixl.pixlui"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:screenOrientation="portrait">
<com.neopixl.pixlui.components.textview.TextView
android:id="#+id/textViewpixl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world"
pixlui:copyandpaste="false"
pixlui:clearclipboardcontent="true"
pixlui:typeface="Lato-Light.ttf"
android:layout_below="#id/btnRebate"
/>
</RelativeLayout>
When I build my project it fails with 10 errors all referencing "already contains a definition for..." with error cs0102 inside the pixlUI files.
Ex: .../pixlUI/obj/Debug/generated/src/Com.Neopixl.Pixlui.Components.Edittext.IEditTextBatchListener.cs(59,59): Error CS0102: The type Com.Neopixl.Pixlui.Components.Edittext.AddNewCharEventArgs' already contains a definition forp0' (CS0102) (pixlUI)
I've tried troubleshooting this but it appears to be either an issue with pixlUI or conflict with something already in my solution. Does anyone have an idea on how to solve this?
First of all, you should change the Build Action for the pixelui.jar to EmbeddedJar.
Then you need to add the following to your binding's Metadata.xml file:
<!-- Bindings added to rename event parameters -->
<attr path="/api/package[#name='com.neopixl.pixlui.components.edittext']/interface[#name='EditTextBatchListener']/method[#name='addNewChar']/parameter[#name='p0']" name="name">editText</attr>
<attr path="/api/package[#name='com.neopixl.pixlui.components.edittext']/interface[#name='EditTextBatchListener']/method[#name='deleteKeyboardButton']/parameter[#name='p0']" name="name">editText</attr>
<attr path="/api/package[#name='com.neopixl.pixlui.components.edittext']/interface[#name='EditTextBatchListener']/method[#name='deleteKeyboardButton']/parameter[#name='p1']" name="name">emptyText</attr>
<attr path="/api/package[#name='com.neopixl.pixlui.components.edittext']/interface[#name='EditTextFocusListener']/method[#name='loseFocus']/parameter[#name='p0']" name="name">editText</attr>
<attr path="/api/package[#name='com.neopixl.pixlui.components.edittext']/interface[#name='EditTextFocusListener']/method[#name='requestFocus']/parameter[#name='p0']" name="name">editText</attr>
Rebuild your bindings then you should be able to use it in your Android app.
Here's a screenshot from the sample project:
If I create a new XML-file (using the default Android Studio "Create Linear Layout"), Studio makes a file with content:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
If I (right)-click "Analyze... → Inspect Code" the result window throws 2 times:
"Namespace is not bound" and references to line 3 and 7 (the LinearLayout-tags). Is it a bug in Studio?
If you get the error:
Namespace 'tools' is not bound:
Example:
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
tools:replace="android:theme"
/>
Add xmlns:tools="http://schemas.android.com/tools" at the top of the manifest (or activity).
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mypackage"
xmlns:tools="http://schemas.android.com/tools">
You must copy everything except the first line <?xml version="1.0" encoding="utf-8"?> from your xml file, create a new xml layout file and erase everything but the first line, then paste the copied content into the new file below the first line. Then you use the new layout file instead of the old one.
Note: This is just my interpretation of leo's answer, I don't know if it works or not and cannot test it because I don't have the same problem as you guys.
try this:
in android studio 2.2.3 press F2 to jump between the warning then press Alt+Enter; this created the following reference:
xmlns:app="http://schemas.android.com/apk/res-auto"
and fixed the issue.
Moreover, I checked my XML files and all have this encoding version:
?xml version="1.0" encoding="utf-8"?
Add:
xmlns:app="http://schemas.android.com/apk/res-auto"
to yor manifest tag
I just added in the xml on the root widget this line:
xmlns:tools="http://schemas.android.com/tools"
An example of this is:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="match_parent">
then you can use attributes like:
tools:text="+52"