The syntax ?attr/something
means "use the value of the attribute named {something} that was defined for the current theme".
selectableItemBackground
is the name of an attribute in your app's theme (usually in styles.xml
). You might not be setting a value for it in your theme, but it might have a value in the parent theme that yours extends from, so your theme has that value as well.
This syntax is useful when you might be using the same layout in places that use different themes. For example, suppose you have two themes:
<style name="Theme.Foo" parent="..." >
<item name="android:textColorPrimary">@android:color/white</item>
...
</style>
<style name="Theme.Bar" parent="..." >
<item name="android:textColorPrimary">@android:color/black</item>
...
</style>
And suppose in one of your layout files you have this:
<TextView
...
android:textColor="?android:attr/textColorPrimary" />
Depending on which of these two themes is being used when the layout is inflated (e.g. when you use setContentView()
), the TextView could have either white or black text color.