Can someone explain the attr?

前端 未结 6 1238
夕颜
夕颜 2021-01-30 00:16

I am looking at the Honeycomb Gallery sample code (here) and I ran across the following code while trying to add action items in my own app:



        
6条回答
  •  自闭症患者
    2021-01-30 00:31

    This blog post does an amazing job going over how to reference values for style-attributes that are defined in the current theme: https://trickyandroid.com/android-resources-and-style-attributes-cheatsheet/

    • When you see ? notation - it means that we are trying to reference a style attribute - a value which may vary depending on current theme. In each specific theme we can override this attribute, so the XML layout doesn't need to be changed, and the correct theme needs to be applied.

    • When you see the @ notation - we reference actual resource value (color, string, dimension, etc). This resource should have an actual value. In this case we know exactly what value we are dealing with.

    Here's an example:

        
    
        
    

提交回复
热议问题