qstumn / badgeview Goto Github PK
View Code? Open in Web Editor NEW支持自由定制外观、拖拽消除的MaterialDesign风格Android BadgeView
License: Apache License 2.0
支持自由定制外观、拖拽消除的MaterialDesign风格Android BadgeView
License: Apache License 2.0
QBadgeView --> lien 157 这个地方 为什么是targetView.setId(View.NO_ID); 而不是用 targetView.setId(targetView.getId()); 这样不是设置了 新view的id和原始的一样了吗? 应该就可以解决点击事件的问题了吧?
什么情况下显示红点
在fragment里面创建,使用的是textview,但是就是不显示效果,在activity里面构建是显示的
想在GridView中某一项ITEM中添加角标,但是崩溃无法使用。
``java.lang.RuntimeException:Unable to start activity ComponentInfo{com.twl.qichechaoren_business/com.twl.qichechaoren_business.purchase.view.PurchaseManageActivity}: java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class android.widget.CompoundButton$SavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/rb_cart. Make sure other views do not use the same id.
不能设置?Gravity.END | Gravity.CENTER;
only support Gravity.START | Gravity.TOP , Gravity.END | Gravity.TOP , Gravity.START | Gravity.BOTTOM , Gravity.END | Gravity.BOTTOM , Gravity.CENTER?
QQ上的似乎可拖动的范围比可视范围大,BadgeView则似乎比较小,拖几次才能消除
初步判定是是xml文件中使用了weight
I added BadgeView to RecyclerView and I have some problem. For dismissing of Badge I use badge.hide(true);
But when I scroll RecyclerView and after that trying hide Badge I see animation on wrong place.
May you help me?
在实际生产中遇到了需要通过角标删除图片的业务逻辑,望加入更通用的setText(String)的特性。
(有点想pr了。。)
new QBadgeView(mActivity).bindTarget(imageView).setBadgeNumber(5).setBadgeGravity(Gravity.END | Gravity.TOP);
我用的是Gravity.END | Gravity.TOP 显示在imageView右上角 运行起来是在左下角?这个还需要其他设置吗
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.ViewGroup.addView(android.view.View, android.view.ViewGroup$LayoutParams)' on a null object reference
QBadgeView.screenFromWindow(QBadgeView.java:227)
我使用setVisibility(View.GONE);来代替hide
如题,总不能每次都new把
比如阴影消失,RadioGroup中的RadioButton失效,相对布局和约束布局offset是反的。
View inflate = LayoutInflater.from(mContext).inflate(R.layout.base_tipview, this, true);
Button tipBtn = (Button) inflate.findViewById(R.id.button);
Badge badge = new QBadgeView(mContext);
badge.bindTarget(tipBtn);
badge.setBadgeNumber(5);
badge.setBadgeBackgroundColor(getResources().getColor(R.color.home_title_color));
badge.setBadgeGravity(Gravity.END | Gravity.TOP);
不显示 QBadgeView
绑定radiobutton 后点击事件失效
I want to set badge offset from center.
Current implementation does not apply the offset if CENTER is set.
Can you add mGravityOffsetY
and mGravityOffsetX
to mBadgeCenter
if gravity is CENTER too?
Example:
Gravity.CENTER | Gravity.TOP: mBadgeCenter.x = (mWidth / 2f) + (mGravityOffsetX + mBadgePadding); mBadgeCenter.y = mGravityOffsetY + mBadgePadding + mBadgeTextRect.height() / 2f; break;
BadgeView 已经收录到开源**,网址是 https://www.oschina.net/p/badgeview ,请问你在开源**的账号是?
TOP直接不显示了. 只有CENTER有效. 默认的是在图片的左边居中.
我是给imageView设置的
使用的话,混淆有没有需要注意的?
目前普通模式下,超过99后,显示99+,希望能设置这个显示文字
TabLayout 的title text 支持不好,看不见badgeView
我这边给一个button设置了badgeView,然后设置偏移,想让它一半显示在外面,然后发现效果并不好,这边应该怎么设置比较好
RT,target为ImageButton,style为ActionButton放到了顶部导航栏,设置gravity为Gravity.END | Gravity.TOP,小红点始终位于右侧中间位置,而不是右上角,新手求解答~
场景为:
badgeview 版本1.1.1
主界面下方使用RadioGroup含有固定个数的RadioBtn,然后通过badgeview给radiobtn设置红点
自己手机没有遇到这样的崩溃事件
崩溃机型:OPPO R9 Plustm A
Cpu架构:arm64-v8a
2 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2430)
3 ......
4 Caused by:
5 java.lang.IllegalArgumentException:Wrong state class, expecting View State but received class android.widget.CompoundButton$SavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/btn1. Make sure other views do not use the same id.
6 android.view.View.onRestoreInstanceState(View.java:13851)
7 android.view.View.dispatchRestoreInstanceState(View.java:13827)
8 android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2904)
9 android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2910)
10 android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2910)
11 android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2910)
12 android.view.View.restoreHierarchyState(View.java:13805)
13 com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:2035)
14 android.app.Activity.onRestoreInstanceState(Activity.java:1054)
15 com.tsou.yezonghui.activity.k.onRestoreInstanceState(Unknown Source)
16 android.app.Activity.performRestoreInstanceState(Activity.java:1009)
17 android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1165)
18 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2403)
19 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2503)
20 android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4099)
21 android.app.ActivityThread.access$1000(ActivityThread.java:160)
22 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1414)
23 android.os.Handler.dispatchMessage(Handler.java:102)
24 android.os.Looper.loop(Looper.java:179)
25 android.app.ActivityThread.main(ActivityThread.java:5491)
26 java.lang.reflect.Method.invoke(Native Method)
27 java.lang.reflect.Method.invoke(Method.java:372)
28 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:961)
29 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
new QBadgeView(this).bindTarget(findViewById(R.id.home_rb_online)).setBadgeNumber(bytesList.size());
这个id指向的是我的radiobutton,然后我还有一个地方Radiogroup设置的有监听,然后,一旦我在这里绑定了这个控件,那边的监听就无效了,感觉应该是点击事件被拦截了。难道这种组合按钮还需要单独去获取再设置红点的显示与否吗?
我在onResume方法中调用
public void setMessageNum() {
AppLog.redLog("sk", "MsgNum:" + Constant.MESNUM);
MsgBadge = new QBadgeView(getActivity()).bindTarget(img_message).setGravityOffset(0, -3, true).setShowShadow(false).setBadgeNumber(Constant.MESNUM);
}
日志打印 E/sk: MsgNum:0
但是没有隐藏badge
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fly.market/com.fly.market.activity.MainActivity}: java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class android.widget.HorizontalScrollView$SavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/app_tab_bottom. Make sure other views do not use the same id.
是不是copy相同ID 的VIew 问题?
在去掉阴影并且图片本身是红色的情况下,红色的角标搭配起来不好看,如果周围能有一圈白边就好了。希望能增加stroke属性,并且可以自定义颜色。
当badgeNumber为两位数时,希望以圆形展示更好看一些,三个及以上以圆角矩形展示。
或者增加一个这样的API也好。
我设置的是Gravity.START | Gravity.BOTTOM,可是有一半看不到了
目前默认的Badge在很多场景下显得有些大了。
刚刚大概看了眼源码,是不是增加一个mDefalutRadius的set接口就可以了呢?没有太仔细看,总之感觉7dp确实大了点。
另,代码风格很赞!
你好, 我有注意到你在文档中提醒不要在 xml 中使用, 我想知道为什么不能使用, 所以尝试使用了下, log 日志只显示了error inflating..., 没有具体指出为什么不能加载.
另外追踪调用效率, 发现在拖动时 系统函数 nSyncAndDrawFrame 占用时间非常长, 达到了 10ms 量级, 测试onDraw 方法直接 return, 占用时间还是一样长, 所以不是 onDraw 里面的问题.
以上两个问题一直让我困惑, 希望你抽空能帮我解答一下疑惑.
作者您好,这个库写的很好,可以省去了自己写拖拽的代码!,希望作者添加只显示小红点,不显示具体数字的属性?如微信的发现按钮,谢谢!
使用方式
if(badge==null){
badge = new QBadgeView(context).bindTarget(img_type);
badge.setBadgeGravity(Gravity.END | Gravity.TOP);
badge.setGravityOffset(DensityUtil.dip2px(context,6), DensityUtil.dip2px(context,6), false);
badge.setBadgePadding(3, true);
badge.setBadgeTextSize(10, true);
badge.setBadgeTextColor(context.getResources().getColor(R.color.mine_secretary_color));
badge.setBadgeBackgroundColor(Color.parseColor("#ffffff"));
}
badge.setBadgeNumber(typeBean.getMesCount());
radiogroup中radiobutton添加角标,貌似那个radiobutton的互斥事件就失效了。这应该是radiobutton的parentview也就是radiogroup被替换了的原因吧,怎么处理这个问题呢?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.