嗨,我正在使用自定义图像的自定义分级栏。我需要在星星之间留出空间。当我增加最小高度和最大高度时,恒星图像保持不变。
<RelativeLayout
android:id="@+id/RelativeLayout01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:padding="5dp">
<TextView
android:id="@+id/allreviews"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Rating"
android:layout_marginLeft="8dp"
android:textSize="14sp" />
<RatingBar
android:id="@+id/reviewallrating"
style="@style/customRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
android:layout_toRightOf="@+id/allreviews"
android:isIndicator="false"
android:numStars="5"
android:stepSize="0.1" />
</RelativeLayout>
款式:
@可拉伸/星级酒吧满
12DIP
12DIP
star_rating_bar_full.xml:
<?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_ratingbar_full_empty" />
<!-- <item android:id="@+android:id/secondaryProgress"
android:drawable="@drawable/star_ratingbar_full_empty" /> -->
<item android:id="@+android:id/progress"
android:drawable="@drawable/star_ratingbar_full_filled" />
</layer-list>
star_ratingbar_full_empty:
<?xml version="1.0" encoding="utf-8"?>
<!-- This is the rating bar drawable that is used to
show a filled cookie. -->
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:state_window_focused="true"
android:drawable="@drawable/star_gray" />
<item android:state_focused="true"
android:state_window_focused="true"
android:drawable="@drawable/star_gray" />
<item android:state_selected="true"
android:state_window_focused="true"
android:drawable="@drawable/star_gray"/>
<item android:drawable="@drawable/star_gray" />
</selector>
star_ratingbar_fullfilled.xml:
<item android:state_pressed="true"
android:state_window_focused="true"
android:drawable="@drawable/yellow_star" />
<item android:state_focused="true"
android:state_window_focused="true"
android:drawable="@drawable/yellow_star" />
<item android:state_selected="true"
android:state_window_focused="true"
android:drawable="@drawable/yellow_star" />
<item android:drawable="@drawable/yellow_star" />
我用了style=?android:attr/ratingbarstyle“在样式上,但输出仍然保持不变。
最佳答案
你只需在PNG的左右两侧添加一些空白。
也就是说,在gimp(或者你使用的任何图形编辑器程序)中增加灰色和黄色png的宽度。
只是画布,没有伸展星星图标。