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.
Related
Can anybody how to remove this parent NavDrawer overlay showing whilst designing layout? (Screen 1).
The overlay is removed when running in actual device (Screen 2).
Because of this I can't design child elements right there in the studio.
Any help would be great!
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Always Visible."
/>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
When you see that gray block with the tag name in it, that means that Android Studio can't resolve the class from the tag in your layout, so it doesn't know what to preview. Often this will happen if you have a typo in your layout file, but then you wouldn't see it working when you actually run the app.
For me, I can make this happen quite easily by using the old support library versions of widgets, since I have AndroidX enabled in my project. For example, just pasting your code in to my IDE gives me the same gray box, but changing your tags to use AndroidX fixes it (android.support.v4.widget.DrawerLayout -> androidx.drawerlayout.widget.DrawerLayout).
Chances are good that your Android Studio just needs a kick in the pants.
I suggest doing a Gradle Sync (File -> Sync Project with Gradle Files) and, if that doesn't work, an Invalidate + Restart (File -> Invalidate Caches / Restart...).
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.
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.
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.
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