Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio Code folding Methods in one line

Android Studio doesn't put all methods in one line when using code folding, and it's rather annoying, because I cannot tell the difference. I don't know why one method can be put in one line, and why another method cannot.

As you can see on this picture below if you look at the method where the cursor is that the upper folding sign is in the line of the name of the function. When I fold it, the method will be in one line. However there are several methods where the upper folding sign in below the line of the name of the function. When I fold it, the method will be in two lines. The first line will include the name of the method, and the second will be "{...}".

enter image description here

How can I fix this? Can this be fixed at all?

Please note the I wouldn't like to put the curly brackets in the line of the name of the function.

like image 547
Dombi Bence Avatar asked Mar 03 '16 10:03

Dombi Bence


2 Answers

Move to :

Settings >> Editor >> General >> Code Folding

You will find Method Bodies and One-line methods check there if you want to make methods in ONE-LINE.

enter image description here

Now Restart android-studio OR for class just close and reopen the same.


To disable outline in code

Go to File -> Settings -> Editor -> General -> Code Folding

Uncheck Show code folding outline


Now shortcuts are,

For Windows:

  Minimize: CTRL + SHFT + '-'
  Expand:   CTRL + SHFT + '+'
like image 184
Amit Vaghela Avatar answered Sep 27 '22 19:09

Amit Vaghela


I noticed the differnce between the lines folded and the lines not folded.

It's the length of the lines.

The lines that are longer than the width of the page (gray line) are not and cannot be folded. But the lines that are shorter that the width when folded are and can be folded.

The width of the page can be adjusted in:

Preferences / Editor / Code Style / Right margin(columns)

like image 38
Dombi Bence Avatar answered Sep 27 '22 18:09

Dombi Bence