我在我的ListView
項目的應用程序中實現了自定義RatingBar
。 自定義樣式ratingbar_red.xml:Android自定義RatingBar圖像工件
<?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_off" />
<item android:id="@android:id/secondaryProgress" android:drawable="@drawable/star_on" />
<item android:id="@android:id/progress" android:drawable="@drawable/star_on" />
</layer-list>
這裏的列表項佈局的一部分:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="15dp" >
<RatingBar
android:id="@+id/li_company_rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginBottom="1dp"
android:isIndicator="true"
android:numStars="5"
android:progressDrawable="@drawable/ratingbar_red"
android:stepSize="1" />
<Button
android:id="@+id/li_company_callbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginLeft="40dp"
android:contentDescription="@string/ContentDescription"
android:drawableLeft="@drawable/phone_icon"
android:drawablePadding="5dp"
android:onClick="callbtn_Click"
android:text="@string/CallButton"
android:focusable="false"
android:focusableInTouchMode="false" >
</Button>
</LinearLayout>
它的工作原理,但是當等級設置,我得到一些奇怪的圖像失真; 2條垂直線的粉色星星下面出現在我的觀點:
下面是star_on.png
star_off.png看起來不錯,如果等級== 0,線條不會出現。
我是android初學者,無法理解問題是什麼。
對不起,我還沒有添加圖片 – Sash0k 2012-02-20 06:00:28