I'm trying to understand the line of code in the title. I understood that ? means that the value will be taken from the Theme. But when it with prefix attrs, I understand that it is defined somewhere in the android system. Also I saw that the selected theme in the app is a child of Theme.AppCompat.NoActionBar that doesn't determine a value for actionBarSize:
<style name="Theme.AppCompat.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<declare-stylable name="Theme">
<attr name="actionBarSize" format="dimension" >
<enum name="wrap_content" value="0" />
</attr>
I also find a theme (with the name Theme) at some GitHub resource that really puts a value to actionBarSize but this Theme doesn't seems to be a parent in any parent chain of the new android api's: Theme.xml
As you've found, the only two attributes that .NoActionBar
provides are:
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
The rest of the attributes are inherited from that style's parent. In the parent style chain for .NoActionBar
is Base.V21.Theme.AppCompat.Light
, which sets actionBarSize
:
<item name="actionBarSize">?android:attr/actionBarSize</item>
In this case, the ?android:
prefix means that it comes directly from the Android platform, which sets it to 56dp
.
You can see all of this if you look at the quick documentation for your style:
All that aside, what android:layout_height="?attr/actionBarSize"
means is that the view should be the same height as the action bar. It doesn't really matter that the final value turns out to be 56dp
; the point is that, whatever the value actually is, this view will be that tall.