2011-07-06 29 views
12

Tôi cần đặt src của ImageView trong phong cách của mình, nhưng tôi không thể tìm thấy một ví dụ hay về bất kỳ ai làm điều này và khi tôi thử mã bên dưới, nó sẽ treo ứng dụng.Android Set ImageView image src trong Style

<ImageView android:src="@style/TitleBarImage"></ImageView> 

<style name="TitleBarImage">  
    <item name="android:layout_width">wrap_content</item>  
    <item name="android:layout_height">wrap_content</item>  
    <item name="android:src">@drawable/whiteButton</item> 
</style> 

Điều này phải đơn giản. Đưa cái gì?

Trả lời

15

xml của bạn là không chính xác:

<ImageView style="@style/TitleBarImage" /> 

Và styles.xml:

<style name="TitleBarImage">  
    <item name="android:layout_width">wrap_content</item>  
    <item name="android:layout_height">wrap_content</item>  
    <item name="android:src">@drawable/whiteButton</item> 
</style> 
+0
Các vấn đề liên quan