I am using static imports in Android Studio as:
import static android.opengl.GLES20.*;
But android studio highlighting every static member/constant related to static import in code as.
I've also tried to look for an option in Settings > Editor > Color & Fonts > Java
but found nothing about changing color.
If you overuse the static import feature, it can make your program unreadable and unmaintainable, polluting its namespace with all the static members you import. Readers of your code (including you, a few months after you wrote it) will not know which class a static member comes from.
by Joshua Bloch.) This is considered bad Java programming practice because when a class implements an interface, it becomes part of the class's public API. Implementation details, such as using the static members of another class, should not leak into public APIs.
In Java, static import concept is introduced in 1.5 version. With the help of static import, we can access the static members of a class directly without class name or any object. For Example: we always use sqrt() method of Math class by using Math class i.e. Math.
Static import is a feature introduced in the Java programming language that allows members (fields and methods) which have been scoped within their container class as public static , to be used in Java code without specifying the class in which the field has been defined.
As your problem is just the highlighting after you used "add on demand static import" and not for the style in general, the solution is pretty simple:
Press Escape. Sometimes you may need to press it twice.
"Settings > Editor > Color & Fonts > Java", in the Scheme then find 'Constant (static final field)' and choose the color you want.
Upd.: Screenshot
Upd. 2: The answer from MatF is the solution to the actual problem asked about.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With