Wrong View Id Format
ID |
kotlin.android_wrong_view_id_format |
Severity |
info |
Remediation Complexity |
trivial |
Remediation Risk |
medium |
Remediation Effort |
low |
Resource |
Naming Convention |
Language |
Kotlin |
Tags |
android, naming |
Description
Flags android:id attribute values whose bare id name does not follow the recommended @+id/snake_case_lowercase convention.
Rationale
A consistent id naming convention keeps R.id.* references discoverable and avoids inconsistencies between layouts written by different developers. The Android tooling and the community-standard ribot guidelines recommend lowercase snake_case ids that start with a letter.
The rule rejects id names that:
-
contain an uppercase letter (e.g.
@+id/myView) -
contain a dash (e.g.
@+id/my-view) -
start with a digit (e.g.
@+id/1stItem)
<!-- Bad: camelCase id -->
<TextView android:id="@+id/myTitleView" />
Remediation
Rename the id to use lowercase letters, digits and underscores.
<!-- Good: snake_case lowercase id -->
<TextView android:id="@+id/my_title_view" />
Remember to update any matching R.id.myTitleView references in source code after renaming.