Android Studio中的XML属性安排 [英] XML attributes arrangement in Android Studio

查看:401
本文介绍了Android Studio中的XML属性安排的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I like to arrange my XML files similar to this question

But I'd like to add an ordering like this:

  1. View id
  2. Style
  3. Layout width and layout heigt
  4. Other layout_ attributes, sorted alphabetically
  5. 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.

解决方案

I'm feeling stupid now, but I figured out my mistake: name of the attribute in question needs to start with android:.

Result:

这篇关于Android Studio中的XML属性安排的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆