<ImageButton
android:id="#+id/btnPostComment"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:background="#android:color/transparent"
android:contentDescription="#string/app_name"
android:paddingRight="8dp"
android:scaleType="fitXY"
android:onClick="#{(view)-> CommentListActivity.onPostComment()}"
android:foreground="android:attr/selectableItemBackground"
android:src="#drawable/ic_post_comment_96px" />
Screenshot
Unknown attribute android:layout , No auto suggestion in XML android
It is very simple. Delete .caches file:
Just close your AS.
Go to .AndroidStudio3.2 folder.
Delete the Caches file (path is: C:\ Users \ user \ .AndroidStudio4 \system)
Restart your AS.
Enjoy.
to fix this you need synchronize your project with gradle file.you can do this by clicking the "synch project with gradle file" button on top right corner.or you can get help here
https://stackoverflow.com/a/53160674/10687310
Related
I have a problem with the code of my joysticks, it displays "Class referenced in the layout file, io.github.controlwear.virtual.joystick.android.JoystickView, was not found in the project or the libraries ' .
I am new in programming, your help will be beneficial to me.
here is the code for the left, same problem for the right
<io.github.controlwear.virtual.joystick.android.JoystickView
android:id="#+id/joystickViewLeft"
android:layout_width="170dp"
android:layout_height="170dp"
android:layout_marginBottom="26dp"
android:layout_marginStart="16dp"
app:JV_backgroundColor="#20000000"
app:JV_borderWidth="4dp"
app:JV_buttonColor="#ffcc00"
app:JV_buttonSizeRatio="35%"
app:JV_fixedCenter="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/joystickViewRight"
app:layout_constraintHorizontal_bias="0.032"
app:layout_constraintStart_toStartOf="parent" />
First import the associated library in build.gradle file.Then rebuild the project.(Or just press sync now button)
Can we change the default Build behavior of Android Studio from Constraint to Relative Layout?
Problem: Sometimes it takes more time to Clean/Rebuild my project. And I never use Constraint Layout, so I want to set the build behavior of Android Studio from Constraint Layout to Relative Layout.
I want every-time I open AS, it should open Relative. Is it possible to achieve?
Make default layout to Relative for current project
First open your .xml file and change your constraint layout to relative layout. Then go to the top menu of your Android Studio with a project open. Then go to "Window" tab, Then select "Store Current Layout as default". If the default is not what you like, download a layout you would like as default and set it as your default layout.
Make default layout to Relative for all projects
Just modify the template layout file which is present in android studio resources
C:\Program Files\Android\Android Studio\plugins\android\lib\templates\activities\common\root\res\layout
Now edit this file simple.xml.ftl and change layout to your choice(Note. for making default relative just copy below code in your simple.xml.ftl file), notice that some layouts require additional elements (e. g. LinearLayout needs android:orientation), save file and create activity in Android Studio, it should work.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
<#if hasAppBar && appBarLayoutName??>
xmlns:app="http://schemas.android.com/apk/res-auto"
</#if>
android:id="#+id/${simpleLayoutName}"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
<#if hasAppBar && appBarLayoutName??>
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:showIn="#layout/${appBarLayoutName}"
</#if>
tools:context="${relativePackage}.${activityClass}">
<#if isNewProject!false>
<TextView
<#if includeCppSupport!false>
android:id="#+id/sample_text"
</#if>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
</#if>
</RelativeLayout>
Keep in mind if you modify the simple.xml, the android studio updater will detect a conflict and prevent applying the update. Keep your copy :)
Quite Easy - just in 3 steps
Goto C:\Program Files\Android\Android Studio\plugins\android\lib\templates\activities\common\root\res\layout
Backup simple.xml.ftl
Modify simple.xml.ftl to below code and save it
<RelativeLayout
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="${packageName}.${activityClass}">
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="Sample"
android:textSize="16sp" />
</RelativeLayout>
Tried and tested on Windows 10 build:gradle:3.0.1
Works for every new activity in the same project and for future projects as well.
Note: Need to modify the simple.xml.ftl file with Admin rights
For this to work out you don't need to edit layout > New > Edit File Templates... your layoutResourceFile and layoutResourceFile_vertical by removing the ${ROOT_TAG} - as I have already tried but that doesn't work.
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 am getting this error:
Description Resource Path Location Type
Syntax error on token "Home", delete this token R.java /UCCPocketCoach/gen/androidapp/fyp/uccpocketcoach line 1659 Java Problem
public static final int btn Home=0x7f060062;
I have no idea where this button is and how to change it, I have tried deleting the token but it regenerates and I have no idea where it is referenced in my code or how to fix it. I have tried joining the space from btn to Home but did not work
Please help
The R,java is auto generated.In case there are error in R.java delete the file and build your project again.
In case the file is not auto generated
try checking your res files for errors.These errors are shown in console in eclipse.
Don't edit inside the R.java file. If needed you can delete the whole gen folder,clean and rebuild.
Please share your xml file too.
May be your project contains the file, that file name contains with "-" (subtraction).
Or check attributes in your xml file. If your xml file contains, id with subtraction remove the subtraction.
ex:
Change button-gackground.xml to button_gackground.xml
Or
Change
<Button
Android: id="#+id/btn-home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Home Button" />
to
<Button
android:id="#+id/btn_home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Home Button" />
Then clean and build the project. If the problem is subtraction. Your project will work.
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.