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

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

Related

how to show design/text tab in xml file in android studio?

I want to make a menu in android studio. when I create a new android resource file in res folder the design/text tab is not show in xml file and I can't put menu item in it. but in other xml files this tab(text/design) is active. my android studio version is 2.1.3.
If you have problems on the layout(and previously the code was running), you should create a new project because sometimes the layout have some rendering problems.
If you want to add an EditText(or similar components using xml code) you can type, for example:
<EditText
android:id="#+id/edit_lastname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
/>
So the components you added will be on the layout.

android error drives me crazy

I'm new to android developing, using eclipse Luna,
When I create my first blank activity project as my book says there should be a layout file (for designing visually the app) in the path"res/layout",
for instance a file named "MyFirstapp.xml" but in my case the layout folder is empty!
I mean there is no where yo see the designing window.
please help me with this problem.
You need to create a new file in the res/layout folder.
Name it e.g. sample_layout.xml
Create a xml based layout or use the graphical interface for it.
Sample code from Android Developers Website:
(http://developer.android.com/guide/topics/ui/declaring-layout.html)
<?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" >
<TextView android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a TextView" />
<Button android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a Button" />
</LinearLayout>
Afterwards you can use the layout by calling:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sample_layout);
}
If you want to get into Android developing please make sure you study Android Developer website:
http://developer.android.com/
There are tons of examples and tutorials!

Why the ImageView class is not found?

i'm having troubles with creating the first android app (Silent Toggle Mode from the pdf "Android.Application.Development.for.For.Dummies" ) with inserting an Imageview in the main.xml file, when I go to the graphical layout, the image isn't showing itself and this error appears:"The following classes could not be found:
- ImageView (Change to android.widget.ImageView, Fix Build Path, Edit XML)"
this is my xml code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="#string/hello_world"
android:orientation="vertical"
tools:context=".MainActivity" >
<EditText android:id="#+id/edit_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="#string/edit_message" />
<ImageView
android:id="#+id/phone_icon"
android:contentDescription="#string/description"
android:layout_width="wrap_content"
android:scaleType="fitXY"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/phone_on" />
<Button
android:id="#+id/toggleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/ToggleSilentMode" />
</LinearLayout>
thanks
This is one issue that I have also run across recently. It was sort of a misleading error to me and kept me stumped for around 30 minutes this morning. It isn't that Android cannot find the class. It is that it is having trouble importing the image source file.
Now the reason that it is having trouble finding the image is because I did not copy the source image into the directory correctly. I have chosen to drag the source file from another folder directory into the appropriate locations. In the process, it did not copy the file over properly. Or it copied it over as just a link to the other resource.
As a result Android does not know what to do with the resource and throws that odd error. In order to resolve this problem, you need to delete the old image sources and then replace them with direct full copies of their equivalents. Then you should see this error go away and the application working as expected from the xml layout code.
I faced the same problem once. To get it out, I replaced all the existing images, now it worked.
I had the same issue, when added a new ImageView in my xml with an image src.
I tried to open this image with Photoshop and get an "module format error". So the image was corrupted. The problem was solved creating a new image similar to the first one.
Hope it works :)

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.

Categories

Resources