博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SVGImageView
阅读量:5023 次
发布时间:2019-06-12

本文共 2509 字,大约阅读时间需要 8 分钟。

In essence, I'm trying to layer multiple ImageViews (one of which is a floor plan, the other a rectangle) on top of each other while still allowing for pinch-zooming. The effect I'm going for is very similar to this post: http:/ /stackoverflow.com/questions/10482229/draw-rectangle-over-imageview-for-highlight-that-can-be-zoom-in-out-in-android?rq=1. However, I want the rectangle to appear at application startup (as opposed to when the user taps the screen) and to update its position over time.

One of my images is an SVG file of a floor plan. I'm using the AndroidSVG library (https:/ /code.google.com/p/androidsvg/) to render it to Android as an SVGImageView. My current implementation allows for pinch-zooming and panning of this SVG file (on application startup: http:/ /imgur.com/SceJuni; after pinch-zooming: http:/ /imgur.com/wL8anKd).

(Sorry for the space in the links; I don't have 10 reputation points so I can't post more than one link)

Now I need to overlay this SVGImageView with a rectangle to denote a location on this map. I want this rectangle to zoom in and out as the SVGImageView zooms in and out. I considered using the ScaleImageView class from this link (https:/ /github.com/matabii/scale-imageview-android) but now I am unsure how to proceed.

Here's the repo:

And heres what I have so far:

import android.app.Activity;import android.graphics.*;import android.os.Bundle;import android.util.FloatMath;import android.util.Log;import android.view.MotionEvent;import android.view.View;import android.widget.ImageView;import android.widget.LinearLayout;import com.caverock.androidsvg.SVGImageView;public void onCreate(Bundle savedInstanceBundle) {    super.onCreate(savedInstanceState);    LinearLayout layout = new LinearLayout(this);    SVGImageView svgImageView = new SVGImageView(this);    svgImageView.setImageAsset("w1a.svg");    svgImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);    svgImageView.setOnTouchListener(new View.OnTouchListener() {        @Override        public boolean onTouch(View v, MotionEvent event) {            ... pinch-zoom and pan ...        }    });    layout.addView(svgImageView,            new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));    setContentView(layout);}

 

上图的svg为:

                  //环形的线
//横着的线
//竖着的线

 由于绘制路径的复杂性,因此强烈建议您使用 SVG 编辑器来创建复杂的图形。

转载于:https://www.cnblogs.com/yaowen/p/5438776.html

你可能感兴趣的文章
Linux内核调试技术——jprobe使用与实现
查看>>
样式、格式布局
查看>>
ubuntu设计文件权限
查看>>
Vue双向绑定原理详解
查看>>
Android基础总结(5)——数据存储,持久化技术
查看>>
关于DataSet事务处理以及SqlDataAdapter四种用法
查看>>
bootstrap
查看>>
http://lorempixel.com/ 可以快速产生假图
查看>>
工程经验总结之吹水"管理大境界"
查看>>
为什么JS动态生成的input标签在后台有时候没法获取到
查看>>
20189210 移动开发平台第六周作业
查看>>
java之hibernate之基于外键的双向一对一关联映射
查看>>
rxjs一句话描述一个操作符(1)
查看>>
第一次独立上手多线程高并发的项目的心路历程
查看>>
ServiceStack 介绍
查看>>
Centos7下载和安装教程
查看>>
无谓的通宵加班之后的思索
查看>>
S1的小成果:MyKTV系统
查看>>
从setting文件导包
查看>>
编写一个函数isMerge,判断一个字符串str是否可以由其他两个字符串part1和part2“组合”而成...
查看>>