2015-12-02 72 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)