Android Layout Editor missing - android

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

Related

I cannot drag drop widgets in Android Studio Layout Editor, I have selected blank activity but there is no app background (frame) in workspace

I have installed all sdk and correctly installed but I have tried multiple times but I cannot fine frame of app where I can insert tool,widgets, button, etc. (Cannot add anything on workspace)
My Android studio window image: https://drive.google.com/file/d/0B8AWJ5JO_e0xVV9KVEE0TUpMYWc/view?usp=drivesdk
Select devices,sdk and theme,like this
image: https://drive.google.com/open?id=0B7VdJKtF9NwGNVFKeE5zZ2pxVHM
Looks like you've gotten rid of the Component Tree.
Try go to the Text-tab and paste
<?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>
or whatever root layout you need...

Uri is not registered for layout in test resources

I'm new at Android testing and I'm trying to test a custom view in an android library and i'm using Android Studio.
I found here : Android: How to test a custom view? that I should use ActivityUnitTestCase and a mock activity.
I have put my xml layout inside projectname/library/src/androidTest/res/layout and my test activity know my layout R id thanks to this : Configuring res srcDirs for androidTest sourceSet.
My issues is in the layout content.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<eu.custom.customView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
In my case, "http://schemas.android.com/apk/res/android" display in red with an error "URI not registered" and the IDE doe's not recognize my custom view if I add it in this xml.
Is there a way to have this layout working without putting it in production code ?
Thanks
Well, in my Eclipse IDE your code looks correct (there are no red lines) may I suggest you to download the ADT-Bundle again or use Android Studio? I think your IDE is corrupted or something in your settings is wrong. Also check if you have downloaded the up-to-date SDK build tools.

xml file vs xml layout

I created two layout files.
Android XML Layout File which created this xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
and an Android XML File
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
From the looks of it they are both the same. When to use one over the other since they are both creating the same xml?
Yeah they are prograticaly the same, there isn't different type of xml. What matters, is the location of the xml (layout, values, ...).
In eclipse, there maybe is a small difference in the IDE view, i'm not sure that you have the Graphical Layout view if you create a Android XML file instead of a layout file (it's a detail because, you still can add this view ;) )
But results apk will be identical.
The reason why you would use an Android XML, is if you wanted to use the Layout Tool (the GUI layout editor). The Eclipse IDE will react to this file differently.
But, the code is the same, so the APK you create will also be the same - it doesn't matter in your final output.
I always use Android XML files, so they integrate into the ADT tools better.
the only difference as far as I can see is that in xml you can't use both "android:layout-width:" and "android:layout-height:" attributes which makes xml for example suitable for the use of menu and item bar and other uses.

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