2014-03-31 57 views
1

我想給RatingBar中的明星添加陰影。我也想用半個星星,所以我不能直接在星形圖像上添加陰影。這是可能實現或將我必須創建一個自定義RatingBar?Android RatingBar明星與陰影/輝光

我做非填充明星透明使用以下繪製:

<?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

嘗試使用背後原來另一家評級酒吧並使其風格的影子。然後將後面的評分欄與頂部的評分欄同步。

<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> 

然後同步評級欄。隨着任何一個改變,另一個也會改變。

+0

我希望能夠使用半星android'stepSize =「0.5」',所以我很確定這是行不通的。 –

+1

我相信它會起作用,或者我不能正確理解你的問題。 –

+0

我現在瞭解您的解決方案。不幸的是,我也想要一些模糊的影子。 –