android 评价 星星大小,Android RatingBar 评价栏 星星 大小 样式 设置

Android系统自带RatingBar,无法直接指定宽高,不然会出现无法全部显示的情况,使用系统自带的两个主题

?android:attr/ratingBarStyleIndicator和

?android:attr/ratingBarStyleSmall

也只能做到固定小版或者大版。

按照以下几个步骤 可以做到自控ratingbar 宽高。

第一步 准备选中何为选中的两种星星,大小相同。

Step-1. You need your own rating stars in res/drawable ...

A full star

Empty star

第二部 为星星定义选中与非选中状态

Step-2 In res/drawable you need ratingstars.xml as follow ...

android:drawable="@drawable/star_empty" />

android:drawable="@drawable/star_empty" />

android:drawable="@drawable/star" />

第三步,为Ratingbar设置style,此处开始正式指定高度。

Step-3 In res/values you need styles.xml as follow ...

@drawable/ratingstars

22dip

22dip

第四部,就可以直接使用了

Step-4 In your layout ...

android:id="@+id/rtbProductRating"

android:layout_height="wrap_content"

android:layout_width="wrap_content"

android:numStars="5"

android:rating="3.5"

android:isIndicator="false"

style="@style/foodRatingBar"

/>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值