Search code examples
androidandroid-studiokeyboard-shortcutsandroid-shortcut

When i format the code in android studio with CTRL+ALT+L my static function() set at first?


Let me explain,

When i format the code [CTRL+ALT+L].

Expected like this:

    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

public static void myCustomFun() {
    //some code here
}

}

BUT I GOT

Result like this:

  public static void myCustomFun() {
    //some code here
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

Can any one tell me what the issue with android studio(V-3.5.3)?


Solution

  • The problem will be that you have stated you want all public or all static methods above other methods. Or you may have "keep overridden methods together". There are a few options.

    Check the arrangement tab to see what you have set:

    enter image description here

    (see 21,22 on my screenshot, it declares static methods above instance methods).