As you know there is many useful shortcuts that improve you coding speed.
One of them is find usage of Class or Method that works with Alt+F7 or Ctrl+b. they works on methods and class names but I wonder how I can find a Usage of XML file like Layout Without Search in project and use Find Usage.
Because the name of XML file is not in the file Like classes and I Always search it's name in whole project. I googled but could not find any answer.
In the Project window, open app > res > layout > activity_main. xml.
Android applications use XML to create layout files. Unlike HTML, XML is case-sensitive, requires each tag be closed, and preserves whitespace. View: An object from Android's built-in View class. It represents a rectangular area of the screen.
All keys are given for windows
CTRL + F for find keywords in a single file
Can do it like this Find usage of an XML| ALT + F7 after you select the XML layout
There is another way(not sure you gonna like it) .. Try to delete a xml and it will not be deleted at the first time.It will show you all the usages of it ask you to confirm you deletion. You can see all the usages at the terminal,so that way you can find them all.
click on view usages button it will show them all
For any short-key File -> Settings -> Keymap -> (you can even Choose Eclipse/Visual Studio short key types in android studio)
Here are some default short keys for windows
Format code | CTRL + ALT + L
Add unimplemented methods | CTRL + I
Show logcat | ALT + 6
Build | CTRL + F9
Build and Run | CTRL + F10
Find | CTRL + F
Find in project| CTRL+SHIFT + F
Find and replace | CTRL + R
Find and replace in project | CTRL + SHIFT + R
Override methods | CTRL + O
Show project | ALT + 1
Hide project - logcat | SHIFT + ESC
Collapse all | CTRL + SHIFT + NumPad +
View Debug Points | CTRL + SHIFT + F8
Expand all | CTRL + SHIFT + NumPad -
Open Settings | ALT + s
Select Target (open current file in Project view) | ALT + F1 → ENTER
Search Everywhere | SHIFT → SHIFT (Double shift)
Code | Surround With | CTRL → ALT + T
Create method form selected code | ALT + CTRL
My personal preference is ctrl+shift+f. It will display a popup dialog in which you can type the thing that you are searching and it will look in your entire project folder.
Alternately there is already a Find Usage feature in xml when you right click it. And it does shows the file that uses it.
In my example I did find the use of my analytics_debug.xml
then a mini console below will show indicating which file uses it. Selecting the file in usage console redirects you to the exact line of code in which the XML is called.
I reproduce this usecase in Ubuntu 16.04, A.S. version 2.1.1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With