Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Android中找到SVG上单击的位置?_Android_Svg - Fatal编程技术网

如何在Android中找到SVG上单击的位置?

如何在Android中找到SVG上单击的位置?,android,svg,Android,Svg,假设我的应用程序显示了一个SVG图像(从SVG转换为可由SVG android库绘制),一旦用户单击它,我需要知道他单击了哪个SVG组 假设我需要将单击坐标传递给某种解析器,该解析器将遍历SVG文件并返回它们所属的组 例如,这样的SVG <?xml version="1.0" encoding="utf-8"?> <!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Bu

假设我的应用程序显示了一个SVG图像(从SVG转换为可由SVG android库绘制),一旦用户单击它,我需要知道他单击了哪个SVG组

假设我需要将单击坐标传递给某种解析器,该解析器将遍历SVG文件并返回它们所属的组

例如,这样的SVG

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">
<svg version="1.1" baseProfile="basic" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
     y="0px" width="100px" height="100px" viewBox="0 0 100 100" xml:space="preserve">


<g id="RCTOP">
    <polygon fill="#4374B9" points="70,25 25,25 25,70"/>
</g>


<g id="RCBTM">
    <polygon fill="#B84545" points="30,75 75,75 75,30"/>
</g>


</svg>

如果单击,则应返回“RCTOP”,例如,35x35;如果单击55x55,则应返回“RCBTM”

如果某处有这样的库,或者我应该从头开始写吗

谢谢

您可以使用

,它可以捕获如下单击事件:

$panzoom.on('panzoomend', function( e, panzoom, matrix, changed ) {
  if ( !changed ) {
    // The user clicked or tapped and did not do a move with panzoom
  }
});
你可以用

,它可以捕获如下单击事件:

$panzoom.on('panzoomend', function( e, panzoom, matrix, changed ) {
  if ( !changed ) {
    // The user clicked or tapped and did not do a move with panzoom
  }
});

是否无法从SVG本身捕获
onclick
事件?例如,
我相信不是,svg android库只是将svg解析成一个可绘制文件。@RogerTravis你找到处理点击的方法了吗?@RogerTravis仍然没有任何问题?是否无法从svg本身捕获一个
onclick
事件?例如,
我相信不是,svg android库只是将svg解析成一个可绘制的文件。@RogerTravis你找到处理点击的方法了吗?@RogerTravis仍然没有任何问题?