Android Studio allows to easily order properties of the views in XML files (layout_width, style, id, etc.) with a simple shortcut CTRL + ALT + L
However I could not find a way to arrange those same properties within style declarations. Is that possible in any way?
Edit: Corresponding issue for starring if not possible
Related
How to find all hardcoded dimensions both in xml layout files and in code in Android Studio? I want to move them over to dimens.xml.
Basically, I want something like https://stackoverflow.com/a/39130143, but for dimensions instead of strings.
This should work -
Press Ctrl + Shift + F or Cmd + Shift + F (in mac) to search in project.
Go to Options and choose Regular Expression.
Now search "((\d)+)dp" in search bar which should give you all the hardcoded dimensions.
If you have dimensions as decimal values you can change the regex pattern accordingly. This one worked in my case.
Also, if you want to search in specific area, you can do that too with this method. Thanks.
You can search all the hard coded dimension in Android studio using Find in path.
Go to
Edit > Find > Find in path
In option tab ->
General -> select Regular expression
Scope -> You can select the sope of the search
File name filter - > you can select FileMasks as *.xml
And you can start the search now, add \ddp or [0-9]dp in Text to find.
Done you can see all the usage.
I think you have to create the custom lint for that, since currently it can check for 0dp in code and use of pixel instead of dimension.
Does anyone know some shortcut to switch between one layout variant to another variant of same layout android studio while editing xml layout?
for e.g. login.xml(layout) to login.xml(layout-land).
There is no such direct shortcut specified in Android Studio manual. An easy way would be to use
Control + Shift + N (Windows) or Command + Shift + O (Mac)
Simply start typing the name of the layout and you can open the variant you want to. Not really useful for a project with a few files; but this saves a lot of time when working with a huge project with 50-75 XML files each with multiple layout variants.
Use Control + Shift + tab (Windows)
While writing code in styles.xml it's takes a lot of time to look which tag could be used inside root-element. Is there some hotkeys to show all possible tags in drop-down list?
We have tag resources and after pressing Ctrl + Space android studio writes 'No suggestions'
CTRL + whitespace (on Windows)
Otherwise refer to the official documentation.
I'm not putting much hope in getting this problem solved, but this is really a pain and I really hope that this can be sorted out...
It is that, is there a shortcut key in Android Eclipse to switch between an xml layout file and its "related" java class (e.g. activity) source file? Much like Visual Studio's Windows Forms Designer (F7 to switch between design view and source code view).
I know that there is not a declarative definition on the relationship of an XML layout and an Activity/Fragment, it is determined during runtime... but still, it is an incredible pain when you are in the source code view and want to refer to a view by id but you (always) cannot remember the name, you need to scan through millions of files in millions of levels of tree depths in the Package Explorer view.
I feel like giving up even now... no one can help...
No, because there isn't a 1:1 relationship between activities and layouts. One activity can have multiple layouts, and 1 layout can appear in multiple activities. I suggest you either adopt a naming standard so you don't have these problems, or just manually open the xml file and keep it open.
In android studio it's ctrl+tab
In Android Studio, you can make use of the Related Symbol... navigation key mapping to toggle between related XML and Java classes.
Depending on your settings and operating system the keyboard shortcut will vary, but you can find out what yours is by looking in Settings -> Keymap -> Main menu / Navigate / Related Symbol...
Otherwise try the following keys:
Ctrl + Alt + F7
Ctrl + Alt + Home
Meta + Ctrl + Up
If you have selected a view in Design View and want to move onto Text View,
CTRL + B
You can also use bookmarks, not exactly what you asked for but can be helpful when jumping around.
F11 - Toggle soft bookmark
Shift + F11 - Open bookmark menu
Ctrl + F11, [mnemonic key] - Create a bookmark with a mnemonic key entry - press any number or letter afterwards
Ctrl + [mnemonic key] - jump to the bookmark created with Ctrl + F11.
Like I said, won't help if you are in the layout and want to jump to the "code behind" but it's a quick way to move between the two while working if you have left bookmarks.
Is there any way to make Eclipse + Android SDK + ADT Plugin offer some sort of auto-complete in XML files if I hit CTRL+Space when my cursor is in a spot such as the ones marked with an * below.
<LinearLayout id* ... lay*>
The thing is that I think that the above was actually working already directly after the initial install - even though it of course never worked within style files.
<style name="ActionBarWrapper" parent="Fill_Parent.Vertical">
<item name="android:layout_height">36dp</item>
<item name="a*"
</style>
There is an icon in the eclispe toolbar to directly access the "new android xml file" wizard.
You could use IntelliJ IDEA instead of Eclipse, it has full auto-completion and works well for Android development.
http://www.jetbrains.com/idea/
The Community Edition fully supports Android, and is FREE
The latest ADT plugin (r9) does have partial auto complete feature in the layout xml.
for example, if you type ctrl-spacebar while the cursor is between 2 tags, you get the list of all avaliable tags (views and layouts). If your cursor is inside a tag, you get a list of all avaliable attributes.
First of all: Thanks for the good advice everybody. Not sure if the following should be an answer or a comment. Going for the answer because comments do not allow enough characters.
After trying out some eclipse plugins (like Rinzo XML Editor ) I found out that it actually worked for some files while it did not work at all for others. After some testing I am now under the impression that there is a difference between creating XML files via...
New > XML
and
New > Other > Android > Android XML File
I double checked that even when both files have exactly the same content (xml-version, encoding, namespace etc.) they behave differently with regards to auto-code-completion depending on the way of file-creation. I also checked the file properties but could not make out any significant differences. Obviously it must be something local or some meta stuff I am overlooking.
I think the different behavior is because when you create the file using "New->XML" the wizard opens the file using the default associated editor to xml content.
If you create a file using "New->Other->Android->Android XML File" I think the wizards tries to open the xml file using a specific xml editor, instead of the one you have configured as default, in this case Rinzo I guess.
In the second case why don't you try finding the xml file in either "Package Explorer" view or "Navigator" view, right click on the xml file and selecting Rinzo through the "Open With" option.