178

Do you know how to check the location of current editing file in the project tree panel (the very left panel of the Android Studio), except manually. (The worst case is that all the folders there are collapsed)

The Navigate->Class shortcut can show me the src file in edit panel (central panel) quickly. Then I want to know the src file's logic location in project tree (left panel), so that I can add some new files in the same package quickly. (e.g. right-click the package and add new Class).

Currently, I have to expand the project tree and find it folder by folder.

Actually, in Xcode there is such a shortcut named "Reveal in Project Navigate"

What a convenient way it is.

I wonder whether this is also supported in Android studio.

Thanks

doniyor
  • 36,596
  • 57
  • 175
  • 260
Roy Ma
  • 1,863
  • 2
  • 11
  • 12
  • 1
    possible duplicate of [Locate current file in IntelliJ](http://stackoverflow.com/questions/1086041/locate-current-file-in-intellij) – Timo Reimann Aug 04 '14 at 08:34
  • 1
    It's exactly much the same as in IntelliJ, so check out this StackOverflow question: http://stackoverflow.com/questions/1086041/locate-current-file-in-intellij – Timo Reimann Aug 04 '14 at 08:36
  • @TimoReimann's reference works. Thanks – Roy Ma Sep 09 '15 at 02:49

10 Answers10

289

You can use the Scroll from Source button in the Project Toolbar in the left of Android Studio.

locate

Another solution is Alt+F1+1. You can also read Locate current file in IntelliJ for more answers.

AliSh
  • 10,085
  • 5
  • 44
  • 76
  • 35
    keyboard shortcut: `Alt-F1, Enter` – wal Jun 14 '16 at 09:22
  • 3
    To be noted that clicking the button did nothing for me, but enabling `Autoscroll from Source` (right click the empty area to the left of said button) now selects the opened file in the tree. Also, after enabling it, the button is removed. – FirstOne Nov 28 '17 at 12:28
  • `Alt-F1` menu is a lifesaver, thanks @wal. `Alt-F1 8` to reveal in finder :) – adamF Apr 25 '18 at 03:03
48

Just enable the following option!

enter image description here

Pato94
  • 784
  • 5
  • 6
  • This is a far better answer than the top one, though technically it isn't exactly what the OP asked. Not sure why it's getting so few upvotes. – Stan Lin Jan 09 '18 at 18:11
  • 4
    I don't have this menu in the latest Android Studio, but right-clicking on "Android" and checking "Always Select Opened File" did the trick for me. – FreeNickname Jul 31 '20 at 10:23
  • I agree, this is the better long term solution. I love this feature in VS code and am happy to see it in Android Studio. – JCrooks Mar 11 '21 at 00:12
17

In Android Studio 4 it is now Always Select Opened File under the Settings menu in the project view.

enter image description here

mharper
  • 3,212
  • 1
  • 23
  • 23
12

For automatic scrolling, you can do following:

You need to ensure Autoscroll to Source and Autoscroll from source is enabled.

auto scroll

Whenever you change the file the Project tree will be highlighted according.

I have observed some slowness and lag if project size is big(several modules or huge code base) and you use short cut Ctrl + N to navigate to a class.

So the alternative would be to either to click following icon: icon

OR

Use keyboard shortcut:

Alt + F1 + 1 or Alt + F1 + Enter

Developer Guy
  • 2,318
  • 6
  • 19
  • 37
Sagar
  • 23,903
  • 4
  • 62
  • 62
7

You can add shortcut (keymap) to "reveal current editing file in project explorer" command.

  1. Press Ctrl + Alt + S, for Windows user, to open Settings
  2. Select Keymap on the sidebar
  3. Find the command using search box, type this into it: select in project view
  4. Right click the result then select Add Keyboard Shortcut
  5. Type any keyboard combination you want, for example, me prefer shortcut Ctrl + K to reveal current editing file on project explorer
  6. Click OK button. It will prompt you to remove keyboard shortcut you typed from existing command, so just click Remove button.

I'm new to android development. I used to code in Sublime Text 3. One of first thing I do to make android development feels more enjoyable is binding all shortcut I used in Sublime Text 3 to Android Studio. Now, it feels like home :)

Ifan Iqbal
  • 3,053
  • 5
  • 28
  • 31
7

For Mac users: Option+fn+F1, then Enter.

Dr.jacky
  • 3,341
  • 6
  • 53
  • 91
5

Android Studio 3.6.3 (April 2020)

Go to Preferences > Keymap & search for "Select in Project View" and assign your keyboard shortcut.

Trev14
  • 3,626
  • 2
  • 31
  • 40
2

Under options menu, select Auto scroll from Source

kaushik
  • 21
  • 1
0

Navigate -> Select In.. -> Project View -> Project

Andrey Petrov
  • 2,291
  • 2
  • 15
  • 12
0

open pref -> Keymap, then search 'select file in project view', not 'select opened file'.

ABDULLOKH MUKHAMMADJONOV
  • 4,249
  • 3
  • 22
  • 40