They are unique on the whole project but can be used on different contexts. The reason is fairly simple: there will be just one R.id.name_of_id variable, though, they cannot be reference from anywhere. I mean, if you have and ID called @+id/my_id which is on the my_layout.xml file, you cannot use it unless you are currently working with my_layout.xml implicitly or explicitly. Implicity by using findViewById after a setContentView(R.layout.my_layout.xml) call (from the activity), or explicity by using it from an object (for instance, when you 'inflate' a layout and assign it to a View object you can do object.findViewById()).