在Android中绘图时如何设置线条的宽度?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1963686/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 03:56:54  来源:igfitidea点击:

How do you set a line's width when drawing in Android?

android

提问by AndroiDBeginner

How to set Line width? What method is used for it?

如何设置线宽?使用什么方法?

回答by John Feminella

Check out Paint.setStrokeWidth().

退房Paint.setStrokeWidth()

You draw by making various Drawableobjects. The objects themselves are separated from the instructions about how to draw them; that's covered by the Paintclass. Paintinstances have a method that allows you set the width of the stroke that will be used to draw the objects, setStrokeWidth(), which is what you want.

您可以通过制作各种Drawable对象来绘画。对象本身与有关如何绘制它们的说明分开;这是Paint课程所涵盖的。Paint实例有一个方法,允许您设置将用于绘制对象的笔划宽度setStrokeWidth(),这正是您想要的。