Android .axml intellisense not working with support library controls - android

I'm currently using VS2013/VS2015 with Xamarin.Android - I'd like to be able to edit layout .axml files with Android intellisense. I use the Automatic editor selector(XML) to edit files. My problem is that while the default Android controls display intellisense fine, as soon as I use a support lib control (like android.support.v7.widget.Toolbar it breaks intellisense for the file (not just the Toolbar control).
For example with the following code, intellisense works fine until I add in the support lib Toolbar:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:orientation="vertical"
a:layout_height="wrap_content"
a:layout_width="fill_parent">
<android.support.v7.widget.Toolbar xmlns:local="http://schemas.android.com/apk/res-auto"
a:id="#+id/Routes_Add_SegmentList_Toolbar"
a:layout_width="match_parent"
a:layout_height="wrap_content"
a:minHeight="?attr/actionBarSize"
a:background="?attr/colorPrimary"
local:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
local:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
<FrameLayout
a:layout_height="wrap_content"
a:layout_width="fill_parent"
a:layout_marginTop="16dp">
<ImageView
a:layout_marginLeft="16dp"
a:scaleType="fitCenter"
a:layout_gravity="left|center_vertical"
a:src="#drawable/start_pin"
a:layout_height="40dp"
a:layout_width="40dp" />
<EditText
a:layout_marginLeft="50dp"
a:layout_marginRight="16dp"
a:id="#+id/Routes_Add_SegmentList_StartSegment"
a:layout_height="wrap_content"
a:layout_width="fill_parent" />
</FrameLayout>
</LinearLayout>
Is there any way to add another xml schema or similar so that it can properly handle non-default android controls? Thanks!

Try
Navigate to root of your solution
Delete .vs folder (hidden folder)
Restart VS
Open solution
Open .axml file
Try and share your thoughts if that works or not.

Related

AndroidStudio ConstrainLayout not working

I am beginner in android studio and having headache with this if someone could help me am i missing something?.... I have problem with Constraint layout, the problem is i put some element(ImageView, Button it does not mater) in layout and constraint it to parent but when I run it in emulator it just is not showing. also it is not showing me those buttons under elements connect BaseLine and remove Constrains for that element.
"screenShot":
<?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=".MainActivity">
<ImageView
android:id="#+id/imageView"
android:layout_width="343dp"
android:layout_height="118dp"
android:layout_marginTop="10dp"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_c`enter code here`onstraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="#tools:sample/backgrounds/scenic[7]" />
</android.support.constraint.ConstraintLayout>
when i run it in emulator it just is not showing
The problem is here :
tools:srcCompat="#tools:sample/backgrounds/scenic[7]"
You need to understand what tools is, so I recommend to you to read a little bit the documentation.
Just a note of it :
It's a namespace that enable design-time features (such as which layout to show in a fragment) or compile-time behaviors (such as which shrinking mode to apply to your XML resources). When you build your app, the build tools remove these attributes so there is no effect on your APK size or runtime behavior.
Instead you have to use to show it on the emulator.
app:srcCompat="#drawable/your_drawable"
Note: remember to add : xmlns:app="http://schemas.android.com/apk/res-auto"
I found the solution.it's difrent in new Android Studio 3.4, You have to Right click on element and option Show Base Line is there now.

Rendering error when using EditText widget inside LinearLayout

I am working on CrimeIntent app in Android Programming:
The Big Nerd Ranch Guide. I got a rendering problem when i put an EditText widget in a LinearLayout file for a fragment (fragment_crime.xml).Here is the code
<?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">
<EditText android:id="#+id/crime_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/crime_title_hint"/>
</LinearLayout>
I do not want to change the theme.
There is no error in your layout xml... possible it is the plugins and library loading issue in android studio... try to restart it or check the missing libraries and targets.. or check the #string/crime_title_hint if it exists in Strings.xml resources.

Android Layout Editor missing

I tried to open my layout xml files in Eclipse now. And I only gets the error
No XML content. Please add a root view or layout to your document.
Wonder why this is a problem, my xml files are correct, E.G:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/widget32"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#e4e8ed">
<Logic.TouchImageView
android:id="#+id/right_finger"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
I tried to right click the .xml file, and open it with the Android Layout Editor, but I couldn't find this editor in my list. I also tried to add it from the Preferences menu, under the File Associations, but the editor is not showed here. The only android relatated xml editors are:
Android Binary XML editor
Android Common XML Editor
Android Export Editor
Android Manifest Editor
Does anybody know why this happens? The layout editor has so many bugs, and I find it hard to use this tool if google doesn't update it..
try updating android tools via SDK manager, I had this problem once, updating to latest version fixed that

Eclipse running on Linux doesn't autocomplete Android XML

Just recently, my Android XML files which define my layout and etc have stopped autocompleting. When I type android: I used to get a list of options related to Android such as layout_width, etc. Now I get only four options, the first being xmlns="default namespace"
Also the tab to change to the layout designer and other tabs are gone, I am left with a 'design' tab which shows my XML structure and a 'source' tab with the actual XML. I think they are being recognised as normal XML files rather than Android XML files, is there a way to change this?
I am running Eclipse Indigo Version 3.7.0 with the ADT plugin Version 15.0.1.
Here is an example of one of the XML files it isn't working in:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="16dp"
android:background="#FFFFFF"
android:textColor="#000000" ></TextView>
Switch to a new workspace may help.

Android Layout designer doesn't open XML file created in IntelliJ

My main working tool is IntelliJ. So I use it to create XML files and layouts for Android activities. However, if I open such XML file in Eclipse, it does not recognize it as layout file and does not load its GUI designer (I open XML file via Eclipse Layout Editor). If I create an XML file in Eclipse, the GUI designer loads properly.
The very content of Eclipse layout XML filet and IntelliJ layout XML file is 100% identical.
What am I doing wrong?
//////////////////////////////////////////////////////////////
EDIT: I have created new project in IntelliJ. Added some test elements into Main.xml. Exported project to Eclipse format (File->Export to Eclipse...). Closed IntelliJ, opened Eclipse, Imported the newly created project, opened Main.xml with Layout Editor and NOTHING again. This is structure of Main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, MyActivity"
/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="just testing text"/>
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="#drawable/icon"/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="test inside of layout"/>
</LinearLayout>
</LinearLayout>
And this is how Eclipse Layout Editor sees this XML file.
Try this
Right click on that xml file
Select Open With
In that select Android Layout Editor
Once you copy the file to the res/layout folder, right click on the project in the project explorer and hit refresh to let it know Eclipse the file is there. You might need to clean the project and rebuild also.
An xml file does not depend on where you created, it's just text.
Make sure the name given to your xml is just all small letters and underscore, no Caps. I had the same problem and changing the Case worked well
just give it time to generate the view. the bigger your layout file, the longer it takes. what you're seeing is a lack of a progress bar that shows it's doing something. just be patient for a while and it should come up

Categories

Resources