自定义图像评分吧 - secondaryProgress和进度可绘制的叠加,帮帮我吧! (code和假设包括) [英] Custom Image Rating Bar - secondaryProgress and Progress drawables are superposing, help me ! (code and hypothesis included)

查看:276
本文介绍了自定义图像评分吧 - secondaryProgress和进度可绘制的叠加,帮帮我吧! (code和假设包括)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:我删除行

<item
    android:id="@+android:id/secondaryProgress"
    android:drawable="@drawable/ratingbar_full_empty_sc"/>

和它取消穷人效应。所以这的确是一个superpostion问题。现在的感觉是非常笨拙的给一半评级。任何人有一个真正的解决方案?请...

and it cancels the poor efect. so it is indeed a superpostion issue. Now the feeling is very clumsy to give half rating. Anyone has a real solution? Please...

原贴

我尝试实施评级酒吧,但我有一半的人充满了一些问题。我修改现有的code,并依照本<一个href=\"http://stackoverflow.com/questions/5800657/how-to-create-custom-ratings-bar-in-android\">post

I try to implement a rating bar but I have some issue with the half filled ones. I modify existing code and follow this post

下面是奇怪的结果是:

听说过这个问题吗?

我张贴我的code以下

I am posting my code below

 <RatingBar
            android:id="@+id/rating_view"
            style="@style/sc_rating_bar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/padding_medium" />

评级酒吧风格:

    <style name="sc_rating_bar" parent="@android:style/Widget.RatingBar">
    <item name="android:progressDrawable">@drawable/ratingbar_full_sc</item>
    </style>

progressDrawable:

progressDrawable :

<?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/ratingbar_full_empty_sc"/>
<item
    android:id="@+android:id/secondaryProgress"
    android:drawable="@drawable/ratingbar_full_empty_sc"/>
<item
    android:id="@+android:id/progress"
    android:drawable="@drawable/ratingbar_full_filled_sc"/>

</layer-list>

ratingbar_full_empty_sc:

ratingbar_full_empty_sc :

<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@drawable/star_empty2" android:state_pressed="true" android:state_window_focused="true"/>
<item android:drawable="@drawable/star_empty2" android:state_focused="true" android:state_window_focused="true"/>
<item android:drawable="@drawable/star_empty2" android:state_selected="true" android:state_window_focused="true"/>
<item android:drawable="@drawable/star_empty2"/>

</selector>

和他的弟弟,ratingbar_full_filled_sc正是与 star_full2 图像是一样的。

and his brother, ratingbar_full_filled_sc is exactly the same with star_full2 image.

我做了什么错?你可以看到我的截图,充分填充明星和空单图文并茂。

What did I do wrong ? You can see both pictures on my screenshot, full fill star and empty one.

推荐答案

AHAH!我发现了一个小的解决方案,根据我的previous编辑:在 progressDrawable 我修改 secondaryProgress

Ahah ! I found a small solution, based on my previous edit : in the progressDrawable I modify the secondaryProgress into

    <item
    android:id="@+android:id/secondaryProgress"
    android:drawable="@drawable/ratingbar_full_null_sc"/>

和如其名,我把一个空的图像绘制里面:

And as the name indicates I put an empty image as drawable inside :

<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@drawable/star_empty2_null" android:state_pressed="true" android:state_window_focused="true"/>
<item android:drawable="@drawable/star_empty2_null" android:state_focused="true" android:state_window_focused="true"/>
<item android:drawable="@drawable/star_empty2_null" android:state_selected="true" android:state_window_focused="true"/>
<item android:drawable="@drawable/star_empty2_null"/>

</selector>

@绘制/ star_empty2_null 是指图像,大小相同的填充明星和空心星,但什么也没有(我拿着明星的文件,将其清在GIMP和相同像素大小导出)。

The @drawable/star_empty2_null refers to an image, same size as the fill star and empty star, but with nothing in it (I took the star file, clear it in Gimp and export it with same pixel size).

完美流畅的动画,没有更多的视觉叠加!

这篇关于自定义图像评分吧 - secondaryProgress和进度可绘制的叠加,帮帮我吧! (code和假设包括)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆