android 如何检测水平滚动视图中画布上的点击

发布于 2025-01-01 20:41:00 字数 444 浏览 1 评论 0原文

您好,我有一个水平滚动视图,在其中我在画布上绘制了一些弧线,这给了我一组可水平滚动的饼图。现在我需要处理每个饼图的点击事件,有人可以帮助我解决同样的问题吗?

ChartUtility sampleObject=new ChartUtility(getActivity());
sampleObject.draw(new Canvas());
ChartContainerLayout.addView(sampleViewObject);//here chartcontainerlayout is a linear layout which his present in a horizontal scrollview.

我尝试过chartutility类的ontouch事件。但无论是什么操作(单击/水平滚动), event.ACTION 都会以“向下”的形式返回。那么我应该如何识别单个项目的点击事件。

Hi I have a horizontal scrollView and inside it I draw some arcs on canvas which gives me set of horizontally scrollable pie charts. Now I need to handle the on click events of each of the pie charts, could some one help me regarding the same.

ChartUtility sampleObject=new ChartUtility(getActivity());
sampleObject.draw(new Canvas());
ChartContainerLayout.addView(sampleViewObject);//here chartcontainerlayout is a linear layout which his present in a horizontal scrollview.

I have tried the ontouch event of chartutility class. But what ever is the action(either a click/horizontal scroll), the event.ACTION is being returned as "down". So how should I recognize the click event on individual items.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

◇流星雨 2025-01-08 20:41:00

我会将方向设置为水平的 LinearLayout 放入 Horizo​​ntalScrollView 中,然后将每个饼图置于其中的单独布局中。然后在这些布局上设置侦听器。我不会将点击处理与滚动混合在一起。

I would put a LinearLayout with orientation set to horizontal into the HorizontalScrollView and then make each pie chart in a separate layout within that. Then set listeners on those layouts. I would not have the click handling mixed with the scrolling.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文