定制评级栏?

时间:2013-01-21 13:16:49

标签: android android-theme ratingbar

我有一个布局。我在其中嵌入了一个自定义评级栏:

<RatingBar
            android:id="@id/rate"
            style="?android:attr/ratingBarStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="5.0dip"
            android:isIndicator="true"
            android:max="5"
            android:numStars="5"
            android:progressDrawable="@drawable/ratebar_theme"
            android:stepSize="0.1" />

ratebar_theme

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:id="@android:id/background"
        android:drawable="@drawable/star_empty_show"/>

    <item
        android:id="@android:id/secondaryProgress"
        android:drawable="@drawable/star_empty_show"/>

    <item
        android:id="@android:id/progress"
        android:drawable="@drawable/star_filled_show"/>

</layer-list>

项目的star_empty_show文件夹中star_filled_show.png都是drawable个文件。上述代码都没有错误,但在Graphical layout标签中我看到了这个:

Failed to parse file E:\...\res\drawable\ratebar_theme.xml

Error Log我看到了这一点:

  org.xmlpull.v1.XmlPullParserException: Binary XML file line #6: <item> tag requires a 'drawable' attribute or child tag defining a drawable

但是我已经为每个项添加了drawable属性。请知道为什么会出现此错误?

2 个答案:

答案 0 :(得分:2)

简单清理你的项目并重启你的日食,希望它有效。

答案 1 :(得分:0)

试试这个..

<?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

        <item
            android:id="@+android:id/background"
            android:drawable="@drawable/star_empty_show"/>

        <item
            android:id="@+android:id/secondaryProgress"
            android:drawable="@drawable/star_empty_show"/>

        <item
            android:id="@+android:id/progress"
            android:drawable="@drawable/star_filled_show"/>

    </layer-list>
相关问题