Coder Social home page Coder Social logo

badgeview's Introduction

BadgeView

一个可以自由定制外观、支持拖拽消除的MaterialDesign风格Android BadgeView

##Change Log

v1.0.5
添加了getTargetView方法

###一些特性

  • 随意定制外观,包括Badge位置、底色、阴影、文字颜色、大小、内外边距等

  • Badge数字小于0时显示dot,等于0时隐藏整个Badge,在普通模式下超过99时显示99+,精确模式下显示具体值

  • 支持类似QQ的拖拽消除效果(默认关闭)

  • 支持以动画的方式隐藏Badge

how to use:

###1. gradle

    compile 'q.rorbin:badgeview:1.0.5'

###2. code

new QBadgeView(context).bindTarget(textview).setBadgeNumber(5);

###3. 方法说明

code 说明
setBadgeNumber 设置数值
setBadgeNumberSize 设置数值大小
setBadgeNumberColor 设置数值颜色
setExactMode 设置是否显示精确模式数值
setBadgeGravity 设置Badge相对于TargetView的位置
setGravityOffset 设置外边距
setBadgePadding 设置内边距
setBadgeBackgroundColor 设置背景色
setShowShadow 设置是否显示阴影
setOnDragStateChangedListener 打开拖拽消除模式并设置监听
hide 隐藏Badge

###4.在ListView或者RecyclerView中使用 可参考demo中ListViewActivityRecyclerViewActivity

###5.一些注意事项

  • 请不要在xml中创建Badge
  • Badge和TargetView绑定是采用替换TargetView的Parent方式实现的,同时将Parent的Id和TargetView的Id设置成一样来保证不会在RelativeLayout中出现位置错乱问题,所以在bindTarget后再次使用findViewById(TargetViewId)得到的会是Parent而不是TargetView,此时建议使用Badge.getTargetView方法来获取TargetView,如果您有更好的解决方式并愿意和我分享,请在Issues中提交给我或者给我发邮件,谢谢。

###6.更新计划

1 . 显示文字 2 . 自定义复杂的背景 3 . 多种隐藏动画

####Change Log History

v1.0.4
1. 修复在hide、bindTarget在某些情况下会出现异常崩溃的BUG
2. BadgeGravity新增CENTER | TOP、CENTER | BOTTOM、CENTER | START、CENTER | END
3. demo中添加了在ListView、RecyclerView中使用的例子

v1.0.2
1. 修复了在ScrollView中bindTarget会导致拖拽消除时起始拖拽位置不正确的BUG
2. 减少了隐藏动画的碎片数量,降低内存占用

###5.Thanks For

https://github.com/mabeijianxi/stickyDots

#LICENSE

Copyright 2017, RorbinQiu

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

badgeview's People

Contributors

qstumn avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.