2017-10-07 51 views
1

我在我的應用程序中使用了RatingBar。我想刪除陰影(它們在截圖上標有下劃線),但我不知道如何去做。在RatingBar中禁用陰影

我的風格:

<style name="RatingBar" parent="Theme.AppCompat"> 
    <item name="colorControlNormal">@color/colorAccent</item> 
    <item name="colorControlActivated">@color/colorAccent</item> 
    <item name="colorControlHighlight">@color/colorAccent</item> 
    <item name="colorPrimary">@color/colorAccent</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 

你能告訴我如何刪除陰影?

Shadow in RatingBar

+0

嘗試在您的主題中設置標高爲0dp –

+0

我試過了。它不起作用 –

+0

您是否找到解決方案?也面臨同樣的問題! –

回答

0

我面臨同樣的問題了。我想到了。 1索引處的drawable改變陰影顏色。您可以將其設置爲實際填充的星形顏色的顏色要淺得多。

RatingBar ratingBar = footer.findViewById(R.id.ratingBar); 
     LayerDrawable stars = (LayerDrawable) ratingBar.getProgressDrawable(); 
     stars.getDrawable(0).setColorFilter(Color.parseColor("#b0b0b0"), PorterDuff.Mode.SRC_ATOP); 
     stars.getDrawable(1).setColorFilter(Color.parseColor("#fff9ee"), PorterDuff.Mode.SRC_ATOP);// This line changes the color of the shadow under the stars 
     stars.getDrawable(2).setColorFilter(Color.parseColor("#FEBE55"), PorterDuff.Mode.SRC_ATOP); 
     ratingBar.setProgressDrawable(stars);