viewportwidth/height对Android可绘制对象有什么影响 [英] What is the impact of viewportwidth/height on Android drawables

查看:1913
本文介绍了viewportwidth/height对Android可绘制对象有什么影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从SVG资产导入的可绘制矢量.有时,我必须调整大小.通常我会更新宽度和高度.我无法解决的是viewportwidth和高度如何影响svg.似乎更改这些尺寸可能会使svg超出可见区域的视线.

I have an vector drawable I imported from an SVG asset. Sometimes, I have to adjust the size. Usually I update width and height. What I can't work out is how viewportwidth and height also impact the svg. It seems changing these dimensions can push the svg out of view within the visible area.

这些度量单位代表什么?分别与宽度和高度有什么关系?与往常一样,来自Google的文档严重不足.有人可以详细说明吗?

What do these units of measurement represent ? What is it's relationship with width and height respectively ? The documentation from Google is, (as usual), woefully inadequate. Could someone please elaborate ?

推荐答案

viewportWidthviewPortHeight定义在其中绘制VectorDrawable内容的文档区域.它们等效于SVG viewBox的宽度和高度字段.如果需要进一步的说明,请研究SVG viewBox的工作原理.

The viewportWidth and viewPortHeight define the area of the document that the content of the VectorDrawable is drawn within. They are equivalent to the width and height fields of an SVG viewBox. Research how an SVG viewBox works if you need further explanation.

因此,假设您的形状是100宽100的矩形.通常,您的viewportWidthviewPortHeight都应设置为100.这样Android才能知道基础形状的尺寸.

So imagine your shape is a rectangle that is 100 wide and 100 height. Your viewportWidth and viewPortHeightshould normally both be set to 100. So that Android knows the dimensions of the underlying shapes.

widthheight属性告诉Android VectorDrawable的默认(本征")呈现大小.您可以想到这些,例如PNG或GIF(就此而言为SVG)的宽度和高度.

The width and height attributes tell Android what the default ("intrinsic") rendering size of the VectorDrawable should be. You can think of these like the width and height of a PNG or GIF (or SVG for that matter).

因此VectorDrawable的内容可以在100x100的区域内定义.但是,如果您的宽度和高度为24x24,则内容将从100x100缩小为24x24.

So the contents of your VectorDrawable could be defined over an area of 100x100. But if your width and height are 24x24, the contents will be scaled down from 100x100 to 24x24.

所以这就是为什么摆弄viewportWidthviewPortHeight会弄乱VectorDrawable的原因.因此,例如,如果将它们更改为50x50,则最终会变成缩小到24x24的形状的一个角-而不是整个形状.

So that's why fiddling with the viewportWidth and viewPortHeight messes with the VectorDrawable. So for instance, if you change them to 50x50, you would end up with one corner of the shape scaled down to 24x24 - instead of the whole shape.

这篇关于viewportwidth/height对Android可绘制对象有什么影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆