2015-12-02 65 views
0

我正在使用Android的默認rating bar,有一個奇怪的灰色邊框已表示去除邊框,我想刪除它們。安卓:排名的酒吧

請注意::計算器上的很多答案建議使用自己的圖像,但我不想,有沒有任何要刪除邊框方法?

我的代碼::

<RatingBar 
    android:id="@+id/layout_fragment_home_recycler_view_rating_bar1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:numStars="5" 
    android:stepSize="1.0" 
    android:rating="4.0" 
    style="?android:attr/ratingBarStyleSmall" 
    android:layout_marginTop="10dp" 
    android:layout_marginBottom="7dp" 
    android:layout_marginLeft="7dp" /> 

什麼我得到

enter image description here

+0

你能在這裏展示我們的形象 – Soham

+0

更新你的答案,所以我們可以幫助您 –

+0

@Soham編輯代碼 – Ravi

回答

1

只是刪除

style="?android:attr/ratingBarStyleSmall" 

從佈局

0

創建自定義樣式,以你的等級吧

<style name="RatingBarStyle" parent="@android:style/Widget.RatingBar"> 
    <item name="android:progressDrawable">@drawable/ratingbar_selector</item> 
    <item name="android:minHeight">34dp</item> 
    <item name="android:maxHeight">34dp</item> 
</style> 

你的評價欄選擇

繪製/ ratingbar_selector.xml

<item android:id="@+android:id/background" 
    android:drawable="@drawable/..." /> 

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

<item android:id="@+android:id/progress" 
    android:drawable="@drawable/..." /> 
+0

我並不想用繪製,我已經提到,在我的問題。 – Ravi

+0

請提供其他解決方案嗎? – Ravi

+0

提供XML代碼,然後以及如何你的形象的樣子,可能是你錯過一些attributs –

-1

試試這個,它不需要的圖像。

public static void setRatingStyle(RatingBar ratingbar, int ratingNormalColor, int ratingProgressColor) { 
    LayerDrawable stars = (LayerDrawable) ratingbar.getProgressDrawable(); 
    stars.getDrawable(0).setColorFilter(ratingNormalColor, PorterDuff.Mode.SRC_ATOP); 
    stars.getDrawable(2).setColorFilter(ratingProgressColor, PorterDuff.Mode.SRC_ATOP); 
} 
+0

只chnages顏色,不刪除邊框 – Ravi

+0

我不認爲這是可能的可繪製出 – Srikanth

0

這爲我工作:

RatingBar coachRating = (RatingBar) findViewById(R.id.rcoach_rbr_rating); 
LayerDrawable stars = (LayerDrawable) coachRating.getProgressDrawable(); 
stars.getDrawable(2).setColorFilter(ContextCompat.getColor(itemView.getContext(), 
         R.color.colorAccent),PorterDuff.Mode.SRC_ATOP); // for filled stars 
stars.getDrawable(1).setColorFilter(ContextCompat.getColor(itemView.getContext(), 
         R.color.white), PorterDuff.Mode.SRC_ATOP); // for half filled stars 
stars.getDrawable(0).setColorFilter(ContextCompat.getColor(itemView.getContext(), 
         R.color.white), PorterDuff.Mode.SRC_ATOP); // for empty stars 

參考:How can I set the color of android rating bar's stroke? (Not the color of the stars but the BORDER)