Witam Używam niestandardowego paska ocen z niestandardowymi obrazami. Muszę zapewnić przestrzeń między gwiazdami. Kiedy zwiększam minimalną wysokość i maksymalną wysokość, obraz gwiazdy pozostaje taki sam.Jak zapewnić odstępy między gwiazdkami gwiazdek z systemem Android?
<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>
style: @ odkształcalne/star_rating_bar_full 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" />
Użyłem style = "? Android: attr/ratingBarStyle" w stylach, ale nadal pozostaje taki sam.
Możesz po prostu dodać trochę pustej przestrzeni do ** lewej i prawej strony ** swoich plików PNG. Przy okazji ... jak są "minimalna wysokość i maksymalna wysokość" związane z ** szerokością **, na którą chcesz działać? –
w porządku. Używałem szerokości pasków ocen jako match_parent, ale idzie ona z wieloma gwiazdami, tzn. więcej niż 5 gwiazdek i rozmiar jest zbyt mały. – Shadow
Nie. Wystąpił problem z komunikacją. Pozostaw szerokość paska ocen jako 'wrap_content'. Zwiększ szerokość szarych i żółtych plików PNG w pliku ** GIMP ** (lub dowolnym ** edytorze graficznym **, którego używasz). Tylko płótno, bez rozciągania gwiazdy. –