this bug is (finally) fixed in adt 21. the fix is now available in adt 21 preview 9, posted a few minutes ago, here: https://android-review.googlesource.com/#/c/44936/1
the reason you get weird visual artifacts is that if a file contains broken dos line endings (multiple carriage returns without a newline for each carriage return), eclipse gets very confused. that's eclipse issue https://bugs.eclipse.org/bugs/show_bug.cgi?id=375421 .
there are two parts to the fix: (1) first, adt was fixed such that it no longer introduces these \r\r sequences into the document. this makes sure that you don't get new documents which triggers the weird editing behavior, but it does not retroactively fix older documents with these line endings, so if you open them, you still get weird editing behavior.
(2) second, there's a new lint check which looks for broken line endings in documents. this runs incrementally, so if you edit an xml file which has this problem, adt will add an error marker for this problem -- along with a quickfix to perform surgery on the document to fix it.
in short: get adt 21 preview 9; run lint on your projects and look for any complaints about files containing broken line endings, and if it finds any, apply the quickfix. from now on, further edits with the layout editor should keep the files consistently formatted.
fyi, the relevant fix is here: https://android-review.googlesource.com/#/c/44936/
instructions for easily updating sdk tools and the eclipse adt plugin are here: http://tools.android.com/preview-channel
-- tor (from the android tools team)
i had the same issue. the following steps were the solution. link suggest its worked for others.
- go to preferences -> keys
- unbind copy, paste, and cut (hit "apply", then "ok")
- repeat step 1
- restore unbound commands from step 2 (i didn't restore cut, but i'm sure you'd be fine)
notice there are 2 bindings for each of the 3 commands
- unbind secondary function for both copy and paste (leave ctl+c/ctl+v [copy/paste] bound)
at this point you should only have 2 bindings set to perform copy/paste (i.e., ctl+c/ctl+v)
- hit apply -> ok
this solution was found here.
when this bug appears with new versions of adt (which are mandatory for fixing and where bug should not appear often) just use lint tool to fix it..
find it in lint warnings and click yellow bulb icon in upper right corner of that lint warnings list..
hope it will help somebody
i had the same difficulty and finally found the solution: right click in the editor, select
still experiencing this bug on juno (eclipse 4.2.0, adt r20).
my fix: go to window -> preferences -> android -> editors. i have both "format xml using the standard android xml..." and "use eclipse settings for indentation...." checked. this solved the problem for me.
edit: contain faster method, so it was bring to top:
ctrl+f -> fill like that:
- "find" "\r\r\n"
- "replace" "\r\n"
- switch "regular expression" to on
- hit the "replace all" button
- deselect text.
- be happy =)
original was here: just don't hide that issue, if you may fix it. some times even closing the xml file didn't help.
for fix it let's look at the reason of it. first of all turn on "show whitespace characters" (window > preferences > general > editors > text editors > show whitespace characters )
then back to your xml-file.
in scaled image you may see the difference of "\n"-symbol colors;
then just put cursor to that symbol, which is more dark.
look, two lines was selected 0o... that's may be the reason!
so just delete it, and press "enter" or "return" button for add "\n" symbol.
hope it help you.
also you may find the other symbol of endline:
just delete it too, and your xml will have a great look!
p.s. sorry for hyperlinks, i'm newbie and on so i can't upload image or more than 2 links. so hope you'll get the point without additional pictures ;)
p.p.s. thx to guy who vote up, now i can provide this with images.
after some tests, i have found that the option "automatically format the xml edited by the visual layout editor" (in preferences | android | editors) might be the culprit here.
with my tests, i've found that changing a property (such as the layout_gravity) while in graphical layout design mode always screw up the visual display of the file when i go back to the xml (text) mode when this option is on but that i have no problem when it's off.
if you want to format the xml upon your return from the graphical layout design mode, simply use the shortcut ctrl+shift+f. also, i didn't see any problem with using the option "format on save"; even when i use it in the graphical layout mode; so you can use ctrl+s instead while you're still in the graphical layout mode to both save and format your xml.
i've tried other editors options like "show range indicator" or "use characters to show changes in vertical ruler" but i didn't see any difference in behavior with activating or de-activating these options.
finally, to correct the visual display of the file when it's corrupt; i found that using the shortcut: ctrl+a, ctrl+c, ctrl+v is a little easier than closing/reopening the file. this is equivalent to making a select all, copy, paste; effectively copying the whole xml file over itself.
- Moving and vanishing lines of code; trouble with Eclipse's XML Editor
- Best ways to deal with properties values in XML file in Spring, Maven and Eclipses
- Problems with Android XML Editor and Eclipse...Hard to manually edit XML
- How can I scroll left and right in Eclipse editor with the keyboard without moving the cursor?
- ADT/Eclipse - Graphics / display artifacts and moving lines of text in main.xml layout editor
- Want to open a eclipse xml file in code and navigate to a specific line number with reference to its IFile
- Editor with Java / JSP and CSS Code Hinting & Completion
- Android editor Using Eclipse Link XML views to edit code and view graphic?
- Understanding Eclipse debug source lookup with dynamically compiled and loaded code
- ADT eclipse xml layout text editor - often broken until file closed and reopened
- Classpath trouble using JUnit with both Eclipse and Maven
- Testing Android code with JUnit and the JDK
- Code completion issues with the Scala-IDE and Eclipse Juno
- Remove empty lines in eclipse code editor by find/replace (Ctrl+F)
- XML Editor in Eclipse Kepler is not displayed with color
- Android development with notepad-like editor and command line
- Can I compile a Scala project with mixed java and scala code with dependencies both ways in Maven?
- Why are class files different size when compiling the same code in eclipse, and then with the eclipse compiler via ant?
- Eclipse - best XML editor with syntax coloring?
- IDE for AngularJS development with debugging, code complete and profiling capabilities?
- Associate XML files with the Eclipse XML editor
- embed a java code editor with limited scope in a swing application?
- How can one disable the XML editor in Eclipse for .xsd and related files?
- How to build same source code twice with different dependency version, in both Maven and Eclipse?
- editing spring xml source with eclipse/sts - missing "mark occurrences" and "jump to bean in another file"?
- EL autocomplete / code assist with Eclipse and Spring Beans
- Code Assist with Eclipse and PHP Standard/Core Functions
- Parsing java code and adding methods with AST (JDT Eclipse)
- Java Hotswap with Eclipses and Remote Debugging on Local Machine
- Creating a Spring 4 MVC project with annotations and no xml files
More Query from same tag
- Handling Keil C51 keywords in the Eclipse indexer
- Error multiplying numbers in the trillions
- Problem launching Flex Builder 3.x
- Eclipse run configurations empty with TestNG and eCobertura
- Calendar instance in android for AlarmManager
- Eclipse native launcher with non-OSGi application
- Configuration when upgrading from Indigo to Luna Eclipse
- Build and run an Eclipse project manually
- Forcing Eclipse to showing only errors
- Connect with SQL Server 2005 Express with Java
- ArrayIndexOutOfBoundsException in com.ibm.icu.text.BreakDictionary.main in SWT Application
- Eclipse Plugins not appearing in Preferences, Views, or Perspective
- svn error: E204899 by check out using ECLIPSE
- Export EGit preferences
- Uploading contacts using HTTP POST
- How to add a library to eclipse of .jar files that are NOT a "User Library"?
- How to: add a class docstring with Eclipse/Pydev via keyboard shortcut?
- Change link to download every 7 days?
- Tomcat and Eclipse server configuration
- I have the error width cannot be resolved or is not a field (It's on the render.width at the end)
- Eclipse dao component implement error
- How to space out items in a LinearLayout?
- IllegalStateException: Workspace is closed, while calling ResourcesPlugin.getWorkspace()
- Does Eclipse BPMN2 Modeler Support timeDate on Timers?
- Eclipse : Link with editor keyboard shortcut?
- I cannot add C/C++ Nature to Android project in Eclipse
- MBO ResultSet Filters - JDBC Driver
- Using cometD in a tapestry web page
- Multiple APK inside Android Studio Like Eclipse
- How to make multiple subdirectories in Eclipse from existing code