2011-01-30 67 views
2

是否有可能将自定义类作为提供给选择器的drawable?核心问题的确是android是否支持引用自定义类的drawable xml。是否有可能将自定义类作为提供给选择器的drawable?

这里的选择:

<selector 
    xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item 
     android:state_pressed="true" 
     android:state_window_focused="true" 
     android:drawable="@drawable/intensity_tick_empty" /> 
</selector> 

这里的intensity_tick_empty.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<com.somepackage.android.RatingTick 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="20dip" 
    android:layout_height="20dip" 
    android:background="#CCCCCC" /> 

RatingTick是我的自定义类,并将其扩展视图。

非常感谢!

回答

3

您可以使用自定义绘图,但不能使用XML。您将不得不从代码构建选择器以使其工作。

相关问题