简体   繁体   English

回收者视图中的Android高亮圆圈

[英]Android highlight circle in recycler view

Samsung Health Screenshot 三星健康截图

I'm making a bar chart that shows a bar and a date using a recycler view that scrolls horizontally. 我正在制作一个条形图,该条形图使用水平滚动的回收器视图显示条形图和日期。 And I'm wondering how I can create something like the black highlight circle in Samsung health? 我想知道如何在Samsung health中创建类似黑色高光的圆圈?

I thought of setting a background for the date and set the background visible only when the item is in the center of the screen, but I found the Samsung's black circle doesn't just show up or disappear with the date as shown in the picture. 我想到为日期设置背景,并且仅当该项目位于屏幕中央时才设置背景,但是我发现三星的黑色圆圈不仅随日期显示或消失,如图所示。 How did it achieve the effect to change the part of the color of the date when it is overlapping with the circle? 当日期颜色与圆圈重叠时,如何实现更改日期颜色部分的效果?

Thanks for the help. 谢谢您的帮助。

There is one quick way of doing it using PotterDuff CLEAR mode. 使用PotterDuff CLEAR模式有一种快速的方法。 When you are drawing date text on top of black circle. 在黑色圆圈上方绘制日期文本时。 Use clear mode to change the color of the overlapped text and use setLayerType(View.LAYER_TYPE_HARDWARE,null); 使用清除模式更改重叠文本的颜色,并使用setLayerType(View.LAYER_TYPE_HARDWARE,null); while initializing your custom view. 同时初始化您的自定义视图。

You can learn about PotterDuff here 您可以在这里了解PotterDuff

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM