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.

2 Answers 2

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 + '+'
Sign up to request clarification or add additional context in comments.

8 Comments

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.
have you tried with Method Bodies option enable.
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.
than according to me, what you want is not available.
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?
|
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)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.