3

レイアウトがあります。カスタム評価バーを埋め込みました。

<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_showstar_filled_showは両方ともプロジェクトのフォルダ内の.pngファイルです。上記のコードはどちらもエラーはありませんが、タブに次のように表示されます。drawableGraphical 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各アイテムに属性を追加しています.ypuはこのエラーが発生する理由を知っていますか?

4

2 に答える 2

2

シンプルプロジェクトをクリーンアップし、Eclipseを再起動します。うまくいけばうまくいきます。

于 2013-01-21T13:22:52.807 に答える
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>
于 2013-01-21T13:41:02.167 に答える