Android FILL_AND_STROKE 有什么意义?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3723545/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What's the point of FILL_AND_STROKE?
提问by Jay
I'm trying out the android graphics classes. I wanted to draw some arcs/circles with a fill color and black outline. The Paint class has a style for FILL_AND_STROKE, but there doesn't seem to be a way to set the fill color vs. stroke color. So as far as I can tell it's the same as FILL?
我正在尝试 android 图形类。我想用填充颜色和黑色轮廓绘制一些弧线/圆圈。Paint 类具有 FILL_AND_STROKE 的样式,但似乎没有设置填充颜色与笔触颜色的方法。所以据我所知,它与 FILL 相同?
So what's the point of FILL_AND_STROKE if you can't set a separate fill and stroke color? I haven't managed to find a good explanation.
那么,如果您不能设置单独的填充和笔触颜色,那么 FILL_AND_STROKE 的意义何在?我还没有找到一个很好的解释。
(I solved my simple problem by doing a fill first, then a stroke, naturally)
(我通过先填充,然后自然地描边来解决我的简单问题)
Edit: I ran into this bug report: http://code.google.com/p/android/issues/detail?id=4086
编辑:我遇到了这个错误报告:http: //code.google.com/p/android/issues/detail?id=4086
Comment 4 and 5 seem to imply that FILL_AND_STROKE is basically the same as FILL and it will be 'fixed' in 2.2. I guess they'll add a new color?
注释 4 和 5 似乎暗示 FILL_AND_STROKE 与 FILL 基本相同,它将在 2.2 中“修复”。我猜他们会添加一种新颜色?
采纳答案by WarrenFaith
afaik: FILL fills your circle, while FILL_AND_STROKE also draws the border. If you increase the size of the stroke, it should result in different circles sizes (only visual!)
afaik: FILL 填充您的圆圈,而 FILL_AND_STROKE 也绘制边框。如果你增加笔触的大小,它应该会导致不同的圆圈大小(只是视觉上的!)
Think about this: you draw a circle by hand with a small sized pencil. The radius is what you wanted. If you now take a big brush and draw the circle again, your radius is much bigger... (i hope its understandable O.o )
想一想:你用小号铅笔手工画一个圆圈。半径就是你想要的。如果你现在拿一把大刷子再次画圆,你的半径会大得多......(我希望它可以理解哦)
回答by Elye
I guess the FILL_AND_STROKE
is particularly useful, if one would animate between STROKE
and FILL
, while wanted to retain the size of the drawn object.
我想FILL_AND_STROKE
是特别有用的,如果在STROKE
和之间设置动画FILL
,同时想要保留绘制对象的大小。
I'm giving an example with the first one below is animated between FILL_AND_STROKE
to STROKE
, while the second is on just FILL
to STROKE
. You could easily see the size shrink.
我举了一个例子,下面的第一个动画在FILL_AND_STROKE
to之间STROKE
,而第二个在FILL
to 之间STROKE
。您可以轻松看到尺寸缩小。
Hence FILL_AND_STROKE
is pretty handy here to make size as consistent as possible with others that have STROKE
, without have to manually adjust the size of the drawn object (which is complicated)
因此,FILL_AND_STROKE
在这里使大小尽可能与其他具有 的大小保持一致非常方便STROKE
,而不必手动调整绘制对象的大小(这很复杂)
回答by Damon Smith
Yes it's a bit silly. The only use for it is if you want to change between a stroke only and a filled circle then you can use FILL_AND_STROKE to keep the size of the circle the same.
是的,这有点傻。它的唯一用途是如果您想在仅笔划和实心圆之间进行更改,那么您可以使用 FILL_AND_STROKE 来保持圆的大小相同。
If you went from STROKE to FILL you would lose the width of the stroke when you drew the circle again.
如果您从 STROKE 转到 FILL,您将在再次绘制圆时丢失笔划的宽度。
回答by TheMadsen
If your stroke style is something other than a solid line (eg a dashed line), you should be able to see the difference. Not that it seems a very useful feature though.
如果您的笔触样式不是实线(例如虚线),您应该能够看到差异。并不是说它似乎是一个非常有用的功能。
Being able to extend the silhouette of something (more complex than a circle) outwards can be extremely useful though, and not easily obtained by other means
能够向外扩展某物(比圆形更复杂)的轮廓可能非常有用,并且不容易通过其他方式获得
回答by Andy
Please see @Shurane's comment.
请参阅@Shurane 的评论。
Just draw it twice, one filled, one stroke and each with one color.
只需绘制两次,一次填充,一次描边,每一次都使用一种颜色。
Worked great for me, and gives the impression of a STROKE and a FILL!
对我来说效果很好,给人一种中风和填充的印象!