问题
I like to arrange my XML files similar to this question
But I'd like to add an ordering like this:
- View id
- Style
- Layout width and layout heigt
- Other
layout_
attributes, sorted alphabetically - Remaining attributes, sorted alphabetically
Example:
<Button
android:id="@id/button_accept"
style="@style/ButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:padding="16dp"
android:text="@string/button_skip_sign_in"
android:textColor="@color/bluish_gray" />
I had a look at Editor -> Code Style -> XML -> Arrangement
, but the only thing I could do was order every attribute alphabetically. This documentation from IntelliJ couldn't help me I'm still not sure what the namespace
is supposed to do.
Maybe someone here understands it better? The UI gave me the impression, that the order of the matching rules is, what the order of the attributes should be. But somehow it doesn't change or do anything.
回答1:
I'm feeling stupid now, but I figured out my mistake: name of the attribute in question needs to start with android:
.
Result:
来源:https://stackoverflow.com/questions/40089102/xml-attributes-arrangement-in-android-studio