Android Studio Code folding Methods in one line
Asked Answered
L

2

6

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.

Langdon answered 3/3, 2016 at 10:54 Comment(0)
S
11

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 + '+'
Silsbye answered 3/3, 2016 at 11:15 Comment(8)
Thank you for your suggestion. This option is already on. As you can see on the picture, some methods are in line, but not all of them.Langdon
have you tried with Method Bodies option enable.Silsbye
Thank you for your new suggestion. The Method Bodies option just simply closes all methods' body, but doesn't put all in one line. Those methods that cannot be fully folded on the picture will be in two lines with the "{...}" in the second line.Langdon
than according to me, what you want is not available.Silsbye
I see, thank you. However could you please help me identify the problem with the methods that cannot be put into 1 line? What the difference between those methods and the others?Langdon
I found the answer. But thank you for your contribution! I gave you an upvote for it. :)Langdon
I'm sorry, but I don't really understand how your update relate to my question, which is already answered. But thank you for your efforts nevertheless! :)Langdon
@GyörgyBenedek it is answer as per your requirement. you want to change method code style these can be done with this answer.Silsbye
L
1

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)

Langdon answered 3/3, 2016 at 13:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.