Dil*_*Ati 15 android android-layout android-xml ratingbar
我已经从这个stackoverflow线程实现了一个自定义评级栏,即使我将numStars设置为5或任何其他数字,它也不会显示多个星号
这是守则.
我正在使用矢量绘图用于图像.
main_activity.xml中的 RatingBar
<RatingBar
android:id="@+id/ratingBarValue"
style="@style/Fuel_Indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:numStars="5"
android:stepSize="1.0"
android:max="5" />
Run Code Online (Sandbox Code Playgroud)
Fuel_Indicator样式风格.
<style name="Fuel_Indicator" parent="@android:style/Widget.RatingBar">
<item name="android:progressDrawable">@drawable/fuel_bar_full</item>
<item name="android:indeterminateDrawable">@drawable/fuel_bar_full</item>
<item name="android:minHeight">23dip</item>
<item name="android:maxHeight">25dip</item>
</style>
Run Code Online (Sandbox Code Playgroud)
该fuel_bar_filled.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background"
android:drawable="@drawable/fuel_bar_empty" />
<item android:id="@android:id/secondaryProgress"
android:drawable="@drawable/fuel_bar_empty" />
<item android:id="@android:id/progress"
android:drawable="@drawable/fuel_bar_filled" />
Run Code Online (Sandbox Code Playgroud)
fuel_bar_empty.xml
<selector
xmlns:android="http://schemas.android.com/apk/res/android">`
<item android:state_pressed="true"
android:state_window_focused="true"
android:drawable="@drawable/ic_fuel_empty" />
<item android:state_focused="true"
android:state_window_focused="true"
android:drawable="@drawable/ic_fuel_empty" />
<item android:state_selected="true"
android:state_window_focused="true"
android:drawable="@drawable/ic_fuel_empty" />
<item android:drawable="@drawable/ic_fuel_empty" />
</selector>
Run Code Online (Sandbox Code Playgroud)
fuel_bar_filled.xml
<selector
xmlns:android="http://schemas.android.com/apk/res/android">`
<item android:state_pressed="true"
android:state_window_focused="true"
android:drawable="@drawable/ic_fuel_full" />
<item android:state_focused="true"
android:state_window_focused="true"
android:drawable="@drawable/ic_fuel_full" />
<item android:state_selected="true"
android:state_window_focused="true"
android:drawable="@drawable/ic_fuel_full" />
<item android:drawable="@drawable/ic_fuel_full" />
</selector>
Run Code Online (Sandbox Code Playgroud)
Har*_*iya 26
您的实现是完美的但是您正在使用Vector Drawable
导致此问题.因此,要努力用它尝试更换Vector Drawable
与png
在绘制文件夹图像,看到了魔术的IT工作.
您使用的是Vector Drawable
与layer-list
让你的Vector Drawable
形象是适合整个布局试图取代它png
,这将解决您的问题.
归档时间: |
|
查看次数: |
2968 次 |
最近记录: |