I have opened up a android project but the xml file graphical layout is not being shown..I have searched on stack overflow and found that it can be fixed by clicking create in top right ..but it is greyed out and does not come up...even if i fill all the details of locale,editing config,change android API level to 2.2/3.0 ..The file opens in xml view..Screenshots are attached..
Can anyone let me know what is the problem and its solution.
If the answer is there somewhere on stack overflow..kindly provide the link..i will delete the question..i wasn't able to find the answer myself..
Open With > Android Common XML editor will not work.
The two tabs was missing because of the theme. Try to set your theme back to the default one. Eclipse > Preferences > General > Appearance > Theme combobox > Mac
Related
i'm have a small problem with my android studio IDE, i've made some changes but don't remember exactly where i did made this change in the settings, the problem is that my xml code is always folded, and i want to know how i can change it to be unfolded by default as it should be.
Preferences > Editor > General > Code Folding > XML > XML tags: disable
For Android Studio 4.0 or above
Goto Settings or Press (Ctrl + Alt + S)
And Navigate to Editor = > Code Folding
And uncheck the option XML tags
I am using AS since 4 years. After last update I observed unexpected auto-formatting of XML layout (while typing and with Code -> Reformat Code too).
Here is an example:
When I started typing relative layout, it expanded start tag, width property, height property and closing tag in the same line.
Properties starts after indentation.
No space between views after reformat.
Question
Is this a feature in new AS? then how can I revert it back?
Did I change some setting? What setting should I modify to revert back? (I tried to find on google but could not find anything)
I am using
Android Studio 3.2.1
Build #AI-181.5540.7.32.5056338, built on October 8, 2018
Update
if you facing same issue with Android Studio 3.5 please check below article
Android Studio 3.5 Upgrade XML Reformatting Problems
Open File > Settings > Editor > Code Style > XML
Now in layout file make sure you have selected wrap attributes as Wrap always
Like below screenshot:
for me it's working
Open Settings > Editor > Code Style > XML > Arrangements
Click Set from... text
Select Predefined Styles > Android
Click Apply button
On Android Studio is there a way to remove unnecessary spaces between the attributes and 'end tags' (">" and "/>") when formating xml files?
I can't see this configuration "Code Style" options.
Based on the accept answer below I got a configuration that work for me:
In Android Studio's Preferences, go to Editor > Code Style > XML. Then select the Android tab on the far right. There are options in this tab to customize the formatting of Android XML files (manifest, layouts, etc.). Make sure Use custom formatting settings for Android XML files is checked. Then you can just format that file like you do any other file Code > Reformat Code.
To get rid of the space before closing tags, go to the Other tab. Under Spaces make sure In empty tag and After tag name are un-checked.
When editing XML layout files, Eclipse has a feature called 'wrap in container' (Reformat -> Android -> ...) that lets you select one or several Views and wrap a layout of your choice around it.
Is there something similar in Android Studio?
It's currently being implemented:
Issue 69000: Add the "Wrap In" visual refactoring - Android Issue Tracker
Tor Norbye, Android Issue Tracker Mantainer:
We should implement the "Wrap In" visual refactoring.
Just came across this, and to complete Simas' answer:
using AS1.2, this is easy to achieve...
to set up a Live Template, simply select the View in your layout XML
that you wanna surround. Hit Alt+Shift+Z (surround-with)... a little
popup appears. Click Configure Live Templates.... Or use File->Settings->Editor->Live Templates as described above.
Select the html/xml section and hit the little +. Give it a name and description, then fill in template text:
<LinearLayout
android:orientation="$ORIENTATION$"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
$SELECTION$
</LinearLayout>
Click Edit variables, set Expression:complete(), Default value:vertical... hit OK. Then, find the Define' button for applicable context... and select XML.
You're all set now. To use the template, select the View that you wanna surround in the XML, hit Alt+Shift+Z (surround-with)... a little popup appears. Select the template you just defined... Done!
You can use Live Templates for that. Here's a nice article about them.
Edit:
New templates can be added through File->Settings->Editor->Live Templates.
To find the hotkey for your keymap go to File->Settings and write "Live template". For me it's CTRL + J .
There are similar questions, but none address my specific issue.
I'm rather new to Android development and Eclipse but was able to follow the tutorials A OK.
In fact, I'm able to edit activity_main.xml from a tutorial, but now, in a test project I'm working on, I can't edit my new activity_main.xml (again, different project, same filename).
I created the file by right-clicking on the layout folder then selecting NEW > OTHER > Android XML Layout File. I was able to copy some of the other file so that my file now looks essentially like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
</LinearLayout>
When I type, the cursor moves around (looping through the text) but no characters appear on the screen. Again, in the other XML file I can edit with no problem.
I'm hoping that this is just some newbie problem.
I have had similar problems, though not this exact problem. Sometimes simply restarting Eclipse, or whatever editor you use, can help. Occasionally, Eclipse will not detect changes in your xml so you need to clean and rebuild the project. You can do this by
Winodow --> Project --> Clean...
and choose your project
I know there was an issue that I had which was similar with the editor jumping/replacing lines and such which I believe was fixed in a newer version of Eclipse. If I can find a source later I will edit
Clear all of text in layout activity_main.xml (in code view)
Drag and drop new LinearLayout in layout (in graphical view)
Go to Project -> Clean