我已经在Android上工作了几年,并且在整个过程中,我一直使用下划线在xml中命名ID,例如 blocked_numbers_title :
<TextView
android:id="@+id/blocked_numbers_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Blocked Numbers"
android:gravity="center"
android:textSize="40sp"
android:textColor="@color/colorTextPrimary"
android:textStyle="bold"
tools:ignore="MissingConstraints" />
由于在kotlin中我们可以像访问变量一样直接访问这些id,因此它们在下划线时看起来不太好,因为它们没有遵循camelCase。遵循camelCase在XML中以 blockedNumbersTitle 命名ID是一种好习惯吗?还是有更好的做法?