Tôi đã triển khai RatingBar
tùy chỉnh trong một ứng dụng trên các mục ListView
của mình. Tuỳ chỉnh phong cách ratingbar_red.xml:Phân loại hình ảnh tùy chỉnh của AndroidBiểu đồ tạo tác
<?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>
Dưới đây là một phần của ListItem bố trí:
<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>
Nó hoạt động, nhưng khi đánh giá được thiết lập, tôi nhận được một số đồ tạo tác hình ảnh kỳ lạ; 2 đường dọc bên dưới những ngôi sao màu hồng xuất hiện trên quan điểm của tôi:
Dưới đây là star_on.png
star_off.png trông ổn, và nếu giá == 0, các dòng không xuất hiện.
Tôi là người mới bắt đầu sử dụng Android và không thể hiểu vấn đề là gì.
Xin lỗi vì các liên kết, nhưng tôi không thể thêm hình ảnh nào được nêu ra – Sash0k