Search code examples
androidandroid-studiobutterknife

Robojuice / Butterknife @InjectView AutoFormatting issue in Android Studio


I am adopting the @InjectView theme throughout my project and have a minor issue when it comes to condensing these declarations. After I put in the initial code it looks great in one line like this..

@InjectView(R.id.tv_report_summary_name) TextView tvReportSummaryName;

However if I do an auto format (Ctrl + Shift + F), Android Studio is automatically replacing this with two lines so it looks like:

@InjectView(R.id.tv_report_summary_name)                                     
TextView tvReportSummaryName;

Is there a way to avoid this or modify my formatting options to make this not happen? Any help is greatly appreciated.


Solution

  • When you open Preferences -> Code Style -> Java.

    Choose Tab Wrapping and Braces.

    After that scroll to bottom and there is option to set this style as is shown in the image below:

    enter image description here

    Choose which is wright for you.