MaterialRatingBar

项目地址:DreaminginCodeZH/MaterialRatingBar
简介:与 Google 系应用设计相同、支持拉伸、修正原生实现诸多问题的星级评分条。可直接替换 RatingBar。

Material Design RatingBar with better appearance, compatible with Android 3.0+.

Why MaterialRatingBar?

  • Consistent appearance on Android 3.0+.
  • Extends framework RatingBar.
  • Get the 2dp star border background as in Material Icons and Google apps.
  • Correct custom tinting across platforms.
  • Able to render correctly when layout_width is set to match_parent, as in Google Play Store.
  • Able to scale correctly when layout_height is set to values other than 16dp, 36dp and 48dp.
  • Able to display ratings such as 4.3 correctly, which will be filled to 4.5 by framework's incorrect implementation.
  • Avoid framework's sunken half star visual glitch.
  • Used as a drop-in replacement for framework RatingBar.

Preview

Sample APK

Integration

Gradle:

compile 'me.zhanghai.android.materialratingbar:library:1.0.2'

Usage

Simply replace your RatingBar with MaterialRatingBar, and remember to apply a corresponding style for correct behavior.

For example, to create a normal MaterialRatingBar:

<me.zhanghai.android.materialratingbar.MaterialRatingBarandroid:layout_width="wrap_content"android:layout_height="wrap_content"style="@style/Widget.MaterialRatingBar.RatingBar" />

In order to make your RatingBar take the correct and consistent size on all versions, you will always need to use one of the styles from this library. The trick inside it is android:minHeight and android:maxHeight that controls the drawable height.

You can checkout more small or indicator variants in styles.xml

8 tint-related attributes such as android:mrb_progressTint and app:mrb_progressTintMode are also supported so that they can control the tinting of rating drawables. The default tint color is ?colorControlActivated, and the default tint mode is src_in.

An OnRatingChangeListener interface is also added to MaterialRatingBar, which enables callback while user is dragging, just as the listener in SeekBar.

For a detailed example, you can refer to the sample app's layout, where you can find examples such as tinting and wide layout.

Design

Filled star or star border

The framework's RatingBar uses filling stars with grey color as track, however as per the Material Icons site, star border icons are given.

And as for the Google Play Store and Google I/O app, they are both using the star borders as track.

 

With Google's design practice and aesthetic considerations taken into account, I decided to use the star border style.

Star size

Google Play Store has stars of optical size 24dp, while Google I/O app and frameworkWidget.Material.RatingBar.Indicator have stars of size 36dp (which are of optical size 30dp). (The framework's default size of 64dp is ridiculously large and thus not taken into consideration.)

Also noticing that the Material Icons site gives icons of 24dp (optical 20dp) and 36dp (optical 30dp), I decided to stick to the 36dp approach which is also visually pleasant.

Star border width

The ring for radio button in Material Design has a width of 2dp, and with experiments on other border widths, I decided to adopt the 2dp border width.

The star border icon is drawn with the help of Inkscape, by downloading the star icon SVG from Material Icons, duplicating the outer border path of the star, setting a stroke of 4dp, running stroke to path on it, extracting the inner border path, and finally combining this path and the original outer border path.

Wide layout

Framework RatingBar gives erroneous rendering for RatingBar when layout_width is set to match_parent by tiling the stars without any gap. Since Google Play Store employed the wide design, I implemented it inside this library as well, so that match_parent will work properly for MaterialRatingBar.

Dragging

Google Play Store and Google I/O app both used an implementation other than RatingBar, which means dragging on the bar across stars won't work (it is the functionality of SeekBar). I think this is a handy way of interaction for users, and it enables the setting of 0 star which can be useful if you want to enable users to reset their rating to unrated.

Google 系应用设计相同、支持拉伸、修正原生实现诸多问题的星级评分条。可直接替换 RatingBar。相关推荐

  1. wpf控件设计时支持(2)

    原文:wpf控件设计时支持(2) 这篇介绍在wpf设计时集合项属性添加项的定义和自定义控件右键菜单的方法 集合项属性设计时支持 1.为集合属性设计器识别具体项类型 wpf设计器允许定义集合项的类型,如 ...

  2. wpf控件设计时支持(1)

    wpf控件设计时支持(1) 原文:wpf控件设计时支持(1) 这部分内容几乎是大家忽略的内容,我想还是来介绍一下. 本篇源码下载 1.属性元数据 在vs IDE中,在asp.net,winfrom等开 ...

  3. LeetCode 1381. 设计一个支持增量操作的栈(deque/数组)

    1. 题目 请你设计一个支持下述操作的栈. 实现自定义栈类 CustomStack : CustomStack(int maxSize):用 maxSize 初始化对象,maxSize 是栈中最多能容 ...

  4. 1381. 设计一个支持增量操作的栈

    2020-05-11 1.题目描述 设计一个支持增量操作的栈 2.题解 使用vector在进行增量操作的时候会方便一些,vector支持push_back.pop_back.empty操作. 3.代码 ...

  5. LeetCode 5357. 设计一个支持增量操作的栈

    5357. 设计一个支持增量操作的栈 思路:用数组实现即可 class CustomStack { public:CustomStack(int maxSize) {fill(a,a+1001,-1) ...

  6. 计算机系系徽设计说明,《系徽设计介绍简介模版.ppt

    <系徽设计介绍简介模版 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copy ...

  7. 【最小栈c++】设计一个支持 push,pop,top 操作,并能在常数时间内检索到最小元素的栈

    设计一个支持 push,pop,top 操作,并能在常数时间内检索到最小元素的栈. push(x) -- 将元素 x 推入栈中. pop() -- 删除栈顶的元素. top() -- 获取栈顶元素. ...

  8. 月亮搭配忧郁蓝色系海报设计模板

    它是最冷的色彩.蓝色非常纯净,通常让人联想到海洋.天空.水.宇宙.纯净的蓝色表现出一种美丽.冷静.理智.安详与广阔.蓝色也代表忧郁,这是受了西方文化的影响,这个意象也运用在文学作品或感性诉求的商业设计 ...

  9. web前端项目实例网站_招聘 | 北京 | tSynsth系联设计 建筑设计师 / 室内设计师 / 项目负责人 / WEB前端开发工程师 / 实习生...

    关于我们 系联设计(Tuning Synesthesia ,tSynsth, TS)是一支由多元背景的设计师与软件工程师组成的国际团队,致力于想法与过程让设计 "可持续". 系联专 ...

最新文章

  1. vue注册新节点_vue怎么重新组装slots节点
  2. 怎样学好python-如何学习 Python
  3. 虚拟服务器问题,虚拟主机常见的五大问题
  4. 【漫画详解】用iframe障眼法,骗取用户点击
  5. 用php写出显示客户端ip与服务器ip的代码.,PHP面试题答案
  6. nginx nodejs环境配置_Linux基本开发环境配置git,c++,nodejs,nginx
  7. Q103:磨边的物体(Beveled Objects)
  8. 容器Docker详解
  9. 190109每日一句
  10. 河南高中计算机会考excl,高中信息技术会考EXCEL知识点.pdf
  11. D4 数据分析实例:分析movielens电影数据+pandas核心数据结构
  12. IDEA破解方法,永久激活
  13. 北京内推 | 启元世界招聘虚拟人算法工程师/实习生
  14. 人工智能学习平台汇总
  15. 系列学习 Swagger 之第 2 篇 —— SpringCloud Gateway 整合 Swagger(完结)
  16. cmd 删除系统垃圾文件
  17. 海贼王 动漫 全集目录 分章节 精彩打斗剧集
  18. 运维必备——Zabbix监控系统
  19. 安卓8.0-MT6763平台 st7701s-MIPI转RGB屏调试
  20. OpenCL 学习step by step (11) 数组求和(reduction)

热门文章

  1. 世界上最远的距离 ——泰戈尔
  2. 金榜提名前端小游戏教程(含冒泡,canvas烟花特效,适配pc,手机)内含源码
  3. 黑莓开发学习入门系列,自己动手实现一个日历软件(六)
  4. 用正则表达式抓取电话号码
  5. 面试官:谈谈分库分表吧?
  6. jQuery——B站黑马程序员
  7. STM32F103C8T6 ADC输入电流电压特性
  8. GAMIT 安装 Make sure the common libraries are curren
  9. Linux I/O原理和零拷贝Zero-copy技术全面揭秘
  10. L1-3 打折 (5 分)——2018