繁体   English   中英

如何在搜索栏中获取刻度盘的X和Y位置

[英]How to get the X and Y position of the dial in a seekbar

我需要获得搜索栏“拇指”的X和Y位置。

调用seekbar.getThumb().getBounds()返回一个相对于seekbar的界限。

有没有办法我可以获得相对于整个屏幕的拇指位置?

我最终做了这个,不太确定如何处理那里的5个。 负5恰好是刻度盘x位置的中心。

// tipBar is the seekbar.
int [] location = new int[2];
tipBar.getLocationInWindow(location);
int x = location[0] + tipBar.getThumb().getBounds().centerX() + tipBar.getThumbOffset() - 5; // magic 5
int y = location[1] + tipBar.getThumb().getBounds().centerY();

暂无
暂无

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

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