Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formatting @BindView code

Android Studio by default format Butterknife code in this way:

@BindView(R.id.text_view) 
TextView mTextView

Is there a way to tell Android Studio to format code in one line, like this:

@BindView(R.id.text_view) TextView mTextView

If this is possible I would like this rule to apply only to @BindView annotation.

like image 914
Kacper Kogut Avatar asked Jun 09 '17 11:06

Kacper Kogut


1 Answers

in Android Studio 2.3.3 File -> Settings -> Editor ->Code Style -> Java -> Wrapping and Braces -> Field annotations -> set to "Do not Wrap"

but this will prevent AS to put the new line on all field annotations.

i don't know if it is possible to have this option only for @BindView, however, if you set the option like this, AS will not put all annotations inline. for instance if you have

@Nullable
String foo;

@BindView View bar;

and format the code, AS will leave both annotations as they are.

like image 150
lelloman Avatar answered Oct 14 '22 10:10

lelloman