android布局文件中android:icon="?attr/menuIconCamera"找不到對應圖標路徑


<item android:id="@+id/camera"
    android:title="Camera"
    android:icon="?attr/menuIconCamera"
    android:showAsAction="ifRoom" />

其中圖標不是通常用的@drawable/ic_menu_camera_holo_light,而用?attr/menuIconCamera代替,而找到menuIconCamera,卻沒有圖標對應

<resources>
<declare-styleable name="AppTheme">
    <attr name="menuIconCamera" format="reference" />
    <attr name="menuIconToggle" format="reference" />
</declare-styleable>

SDK中對此一段描述:

For example, here's how you can reference an attribute to set the text color to match the "primary" text color of the system theme:

<EditText id="text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="?android:textColorSecondary" android:text="@string/hello_world" />

Here, the android:textColor attribute specifies the name of a style attribute in the current theme. Android now uses the value applied to the android:textColorSecondary style attribute as the value for android:textColor in this widget. Because the system resource tool knows that an attribute resource is expected in this context, you do not need to explicitly state the type (which would be ?android:attr/textColorSecondary)—you can exclude the attr type.(在這里,android:textColor屬性指定一個樣式的名稱屬性在當前主題。Android現在使用的值應用於Android:textColorSecondary樣式屬性的值為Android:textColor在這個小部件。因為系統資源工具知道一個屬性資源預計將在這種情況下,您不需要顯式地聲明類型(這將是? android:attr / textColorSecondary)-你可以排除attr類型。

 

其實要找到menuIconCamera對應圖標可以在styles.xml中找到

<item name="menuIconCamera">@drawable/ic_menu_camera_holo_light</item>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM