Android RatingBar带阴影/发光的星星

时间:2014-03-31 13:40:38

标签: android shadow ratingbar

我想在RatingBar中为星星添加阴影。我也想使用半星,所以我不能直接在星图上添加阴影。这有可能实现,还是我必须创建自定义RatingBar?

我使用以下drawable使非填充星形透明:

<?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="@android:color/transparent" />
    <item android:id="@android:id/secondaryProgress"
        android:drawable="@android:color/transparent" />
    <item android:id="@android:id/progress"
        android:drawable="@drawable/star" />
</layer-list>

1 个答案:

答案 0 :(得分:1)

尝试使用原始评级栏后面的另一个评级栏,并将其样式设为阴影。然后将后面的评级栏与顶部的评级栏同步。

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_alignLeft="@+id/textView1"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="22dp" >

<RatingBar
    android:id="@+id/ratingBar2"
    android:layout_width="wrap_content"
    android:layout_height="40dp"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="0dp"
    android:layout_marginLeft="5dp"
    android:stepSize="0.5"
    android:focusable="false" />

<RatingBar
    android:id="@+id/ratingBar1"
    android:layout_width="wrap_content"
    android:layout_height="40dp"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="10dp"
    android:stepSize="0.5"
     />

</RelativeLayout>

然后同步评级栏。任何人改变了,另一个也会改变。

相关问题