@jimn You can use View.generateViewId() which generates IDs that won't conflict with R.id values but you may have issues on orientation change because your ID won't be constant without extra work. Put these IDs in ids.xml and a "constant" is generated. Plus, I don't see how that defeats DRY. You're defining the constant in 1 place. I've been down the road trying to totally eliminate XML, but you need the IDs to remain the same so things like focus on a view can be set after orientation change.